Menu
iThemes
WordPress Backup, Security & Maintenance
  • WordPress Hosting
  • BackupBuddy
  • Security
  • Sync
  • Agency Bundle
  • Plugin Suite
  • Training
    • WordPress Gutenberg Help
    • WordPress Tutorials
    • Free Upcoming Webinars
  • Blog
  • Contact
  • Log In
WordPress News and Updates from iThemes
Categories
  • Product Updates
  • WordPress Backup
  • WordPress Block Editor
  • WordPress Ecommerce
  • WordPress for Freelancers
  • WordPress Maintenance
  • WordPress Security
  • WordPress Training Webinars
  • WordPress Tutorials
  • WProsper

How to Hardcode the WordPress Setup Process

Written by Kristen Wright on March 17, 2016

Last Updated on March 17, 2016

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
 
// 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' );
 
?>

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

wordpress setup

Share via:

  • Facebook
  • Twitter
  • LinkedIn
  • More
Other related posts
why WordPress
Why WordPress? 15 Reasons to Use WordPress

How to Move a WordPress Website to a New Domain

How to Install a LAMP Stack

How to Manage WordPress Sites: 75 Tasks To Keep Your Site Running Smoothly

Comments

  1. Paul says:
    May 31, 2016 at 5:32 am

    Are there any benefits to doing it this way over just creating a WordPress install with DesktopServer, setting it up how you like, then just copying that install when you need to start a new WordPress project?

    Reply

Respond

Click here to cancel reply.

Get updates on new themes & plugins plus special discounts

About iThemes

  • #WProsper
  • Friends of iThemes
  • Contact Us
  • Website Accessibility Statement
  • Sitemap

Resources

  • Blog
  • Documentation
  • WordPress Tutorials
  • Free WordPress Ebooks
  • Free Webinar Library
  • Free Upcoming Webinars
  • iThemes Training
  • Affiliates

Customers

  • Member Panel Login
  • Support
  • FAQs
  • Upgrade Policy
  • Licensing
  • Terms and Conditions
  • Refund Policy

Top Products

  • BackupBuddy
  • iThemes Security Pro
  • iThemes Sync
  • Restrict Content Pro
  • WPComplete
  • Agency Bundle
  • WordPress Hosting
  • WordPress Plugins
  • Content Upgrades
  • WordPress Landing Page Plugin
  • BackupBuddy Stash

iThemes Media LLC Copyright © 2021 All rights reserved | Privacy Policy

  • Liquid Web Family of Brands
  • Facebook
  • Twitter
  • LinkedIn
  • More Networks
Share via
Facebook
Twitter
LinkedIn
Mix
Pinterest
Tumblr
Skype
Buffer
Pocket
VKontakte
Parler
Xing
Reddit
Flipboard
MySpace
Delicious
Amazon
Digg
Evernote
Blogger
LiveJournal
Baidu
MeWe
NewsVine
Yummly
Yahoo
WhatsApp
Viber
SMS
Telegram
Facebook Messenger
Like
Email
Print
Copy Link
Copy link
CopyCopied