Menu
iThemes
WordPress Backup, Security & Maintenance
  • Products
    • iThemes Security Pro
    • BackupBuddy
    • Kadence WP
    • Restrict Content Pro
    • iThemes Sync
    • Why buy from iThemes?
  • Bundles
    • Essentials Bundle
    • Plugin Suite
    • WordPress Web Designer’s Toolkit
    • Customer Spotlights
  • Resources
    • Blog
    • WordPress 101 Tutorials
    • WordPress Ebooks
    • Weekly WordPress Vulnerability Report
    • The Ultimate Guide to Starting a Web Design Business
  • Training
    • Upcoming Webinars
    • Free Webinar Library
    • Premium Courses
    • Become a Member
    • Member Login
  • Support
    • Documentation
    • Get Help
    • Product Updates
    • Upgrade Policy
    • Contact
    • Our Mission: Make People’s Lives Awesome
  • Log In
WordPress News and Updates from iThemes
Categories
  • Product Updates
  • WordPress Backup
  • WordPress Block Editor
  • WordPress Ecommerce
  • WordPress for Freelancers
  • WordPress Security
  • WordPress Tutorials
  • WPprosper

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

Kristen Wright
Kristen Wright

Kristen has been writing tutorials to help WordPress users since 2011. As marketing director here at iThemes, she’s dedicated to helping you find the best ways to build, manage, and maintain effective WordPress websites. Kristen also enjoys journaling (check out her side project, The Transformation Year!), hiking and camping, step aerobics, cooking, and daily adventures with her family, hoping to live a more present life.

Share via:

  • Facebook
  • Twitter
  • LinkedIn
  • More
Other related posts
why-wordpress
Why WordPress? 15 Reasons to Use WordPress
manage-wordpress
How to Manage WordPress Sites: 75 Tasks To Keep Your Site Running Smoothly
move-wordpress-new-domain
How to Move a WordPress Website to a New Domain

How to Install a LAMP Stack

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

  • The Team
  • 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
  • WordPress Hosting
  • WordPress Plugins
  • Content Upgrades
  • WordPress Landing Page Plugin
  • BackupBuddy Stash

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

© 2022 All Rights Reserved.

[class^="wpforms-"]
[class^="wpforms-"]
Share via
Facebook
Twitter
LinkedIn
Mix
Email
Print
Copy Link
Powered by Social Snap
Copy link
CopyCopied
Powered by Social Snap