How to Hardcode the WordPress Setup Process

Every WordPress developer has a preset list of tasks that need to be done before they begin developing a new WordPress website. Default settings need to be adjusted and things need to be deleted. But what if you could automate this whole process using some little known code snippets? Standard WordPress Setup Steps What if there was a way to do the following WordPress Setup steps automatically?

Avatar photo
SolidWP Editorial Team
Every WordPress developer has a preset list of tasks that need to be done before they begin developing a new WordPress website. Default settings need to be adjusted and things need to be deleted. But what if you could automate this whole process using some little known code snippets? wordpress setup

Standard WordPress Setup Steps

What if there was a way to do the following WordPress Setup steps automatically?
  • Get rid of the “Just another WordPress site” tagline
  • Change the default category
  • Disable comments automatically
  • Set the permalink structure
  • Delete the “Hello World!” post
  • Delete the default comment on that post
  • Delete the “Sample Page” page
  • Automatically activate a number of plugins
  • Activate the theme you want to use
  • And much more…

A Streamlined WordPress Setup Process

Creating a “ThrowAway Theme” to run cleanup tasks for your initial setup can accomplish ALL of the above tasks. Did you know that in the wp_config.php file you are able to set a WP_DEFAULT_THEME to be activated when the WordPress site starts? This also opens the possibility of creating a single WordPress theme that sets up WordPress the way you want without having to manually do it. 🙂 First you need a 1) theme style.css file and 2) a functions.php file. (that’s it). The style.css file will just include the header meta information, like this:
/*
Theme Name: ThrowAway Theme
Author: Bob Bobertson
Description: Simple theme to run some errands.
Version: 1
*/
Then the functions.php file looks like this: [php] <?php // set the options to change $option = array( // we don’t want no description ‘blogdescription’ => ”, // change category base ‘category_base’ => ‘/cat’, // change tag base ‘tag_base’ => ‘/label’, // disable comments ‘default_comment_status’ => ‘closed’, // disable trackbacks ‘use_trackback’ => ”, // disable pingbacks ‘default_ping_status’ => ‘closed’, // disable pinging ‘default_pingback_flag’ => ”, // change the permalink structure ‘permalink_structure’ => ‘/%postname%/’, // dont use year/month folders for uploads ‘uploads_use_yearmonth_folders’ => ”, // don’t use those ugly smilies ‘use_smilies’ => ” ); // change the options! foreach ( $option as $key => $value ) { update_option( $key, $value ); } // flush rewrite rules because we changed the permalink structure global $wp_rewrite; $wp_rewrite->flush_rules(); // delete the default comment, post and page wp_delete_comment( 1 ); wp_delete_post( 1, TRUE ); wp_delete_post( 2, TRUE ); // we need to include the file below because the activate_plugin() function isn’t normally defined in the front-end include_once( ABSPATH . ‘wp-admin/includes/plugin.php’ ); // activate pre-bundled plugins activate_plugin( ‘wp-super-cache/wp-cache.php’ ); activate_plugin( ‘wordpress-seo/wp-seo.php’ ); // switch the theme to "Builder" switch_theme( ‘builder’ ); ?> [/php]

Follow These Steps to Hardcode the WordPress Setup Process

  1. Upload your WordPress Installation.
  2. Have the “ThrowAway” theme defined in the wp-config.php file.
  3. define( 'WP_DEFAULT_THEME', 'default-theme-folder-name' ); 
  4. Done… once you do the Installation/setup screen, WordPress will start in the “throwaway” theme, do all the tasks, then switch to your main theme.
ithemes-training

Watch the Webinar: Hardcoding the WordPress Setup Process

In this webinar, “The Professor” walks through all the steps above in more detail so you can see how to start streamlining your own WordPress setup process.

Watch the webinar

Did you like this article? Spread the word: