WordPress: Useful Default Configuration Settings Via Plugin

Everybody who installs WordPress quite often knows the problem: You always have to do the same adjustments, for example deleting the Hello World post. That cost time and money. Our friend Thomas Scholz alias toscho had a simple but genius idea, he puts all needed option settings in a Plugin. Just activate the Plugin, deactivate it and delete it. Done!

You can adjust and expand the options as you like. A good overview is the wp-admin/options.php.

 'blank',
        'avatar_rating'             => 'G',
        'category_base'             => '/thema',
        'comment_max_links'         => 0,
        'comments_per_page'         => 0,
        'date_format'               => 'd.m.Y',
        'default_ping_status'       => 'closed',
        'default_post_edit_rows'    => 30,
        'links_updated_date_format' => 'j. F Y, H:i',
        'permalink_structure'       => '/%year%/%postname%/',
        'rss_language'              => 'de',
        'timezone_string'           => 'Etc/GMT-1',
        'use_smilies'               => 0,
    );

    foreach ( $o as $k => $v )
    {
        update_option($k, $v);
    }

    // Delete dummy post and comment.
    wp_delete_post(1, TRUE);
    wp_delete_comment(1);

    return;
}
register_activation_hook(__FILE__, 'set_toscho_defaults');
?>

Here you can download the Plugin by toscho.


Posted

in

by

Comments

21 responses to “WordPress: Useful Default Configuration Settings Via Plugin”

  1. visaap Avatar
    visaap

    This is SUPER handy!!!
    Thanx a lot.

  2. Markus Avatar

    very helpful thank you

  3. Tony Dunsworth Avatar

    This could come in very handy with several site I administer.

  4. Tomáš Kapler Avatar

    This solution is not the best one – FAR better is to have own instal.php in /wp-content which is automaticaly run during instalation. And this instal.php can contain definition of own posts, own users, own configuration, plugins etc. So you will even not need to download and run some plugin, you just have your own wordpress instalation.

  5. JhezeR Avatar

    Trik dan plugin yang sangat cerdas 🙂

  6. Chris Avatar

    With the number of install I do this is going to be a real time-saver.

  7. […] een tweet van @visaap kwam ik op een post van de site WPEngineer.com uit, met als titel "Useful Default Configuration Settings Via Plugin". Hoe je dus gemakkelijk de standaard instellingen van WordPress kunt invullen met behulp van een […]

  8. Peter Westwood Avatar

    The wp-content/install.php solution is a much better way to do this IMHO.

    That way you have full control over the defaults installed!

    http://wpbits.wordpress.com/2007/08/10/automating-wordpress-customizations-the-installphp-way/

  9. Michael Avatar

    @Westi: a lead dev must be right :p
    but i like this little solution without modifying the core files.

  10. Deryck Avatar

    Very usefull! It´s simple and efficient for clients!

  11. Pulsuz Sayt Avatar

    Hi,
    I use WPMU and want to create default widget settings for newly created sub blogs. I want to create deafult widget settings for “text” widget as want to write something into to newly created blog`s sidebar. I use this code to auto add widget:
    ‘My Categories’ ));
    update_blog_option($blog_id, “sidebars_widgets”,
    array(“sidebar-1” => array(“text”),));
    }
    add_action(‘wpmu_new_blog’, ‘default_widgets’);
    ?>

    But this widget adds to sidebar empty. Can you help me to add some text to this text widget as default:
    $title and $text

  12. Florian Weber Avatar

    I’m installing blogs weekly, awesome plugin. It doesn’t take much time to change default settings but it sums up…great little helper!

  13. Paul Cunningham Avatar

    Got to admit, hadn’t thought of either this or the install.php method before.

    Insanely useful for regular installers.

  14. Jessi Hance Avatar

    Does anyone know how you would change the name of the dummy page and turn off comments and pings on it?

    And how to set the Reading settings to use that page for the front page?

    And even how to create another page called Blog and set that for the posts page?

    I don’t ask for much, do I.

  15. David Page Avatar

    @Michael The solution @Westi indicates doesn’t modify core files, the install file is located in wp-content/
    I find it’s really useful to pre-setup new installations with a set of pages, couple of users, change the WP default options, activate a different theme, even pre-activate plugins and set their options. Everything that @Jessi above wants and more.

  16. Philip Downer Avatar

    Looks like there are several different ways to skin a cat in this case. Since the majority of my WordPress developments starts with a custom theme framework, I generally keep a sandbox environment that contains all my basic plugins, functions and theme files.

    Then, when I’m ready to start a new project, I’m able to simply duplicate the database, as well as the file/folder structure to get rolling.

    All settings, users, posts, etc. are kept intact.

  17. Omer Greenwald Avatar

    Very awesome! thanks

  18. Jürgen Avatar

    Don’t forget register_uninstall_hook()
    to delete your values as well:
    delete_metadata()
    delete_option()

    Keep you system clean

  19. Benjamin Charity Avatar

    Can anyone help me transfer this into something that can be triggered by the theme? So that when they enable my theme, certain defaults are set that the theme needs? My PHP isn’t too strong so any help is greatly appreciated!

    Thanks in advance!

  20. Jacob V Avatar
    Jacob V

    But… THAT WAS EXACTLY WHAT I WAS LOOKING FOR!!!

    (sorry for the caps lock but it was intended)

    So nice!