wordpress snippets last updated   : January 29, 2015
we now have 646 snippets

Reset blog back to default settings

wordpress snippet

This snippet will reset wordpress back to the default settings. WARNING please use with care Place this snippet into the functions.php of your wordpress theme and be sure to remove it after settings are reset.

snippet :  PHPcopy
function set_theme_defaults() {
    $o = array(
        'avatar_default'            => '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);
register_activation_hook(__FILE__, 'set_theme_defaults');
source →

Did you like this post? If so please share it with your friends. Thanks!

  • http://www.cliffpaulick.com Cliff Paulick

    What about making a test installation and letting anyone from the Internet login (like testing out the backend of a theme or of WordPress in general – letting them install plugins and such) and then doing a reset every 12 hours or something – to basic WordPress – only my specified plugins (or no plugins), and no other settings or authors or anything – a full reset?

    • http://wpsnipp.com Kevin Chard

      I guess you could do this however I’m not sure providing access to the admin would be worth while. The idea is more for theme developers so they could test out things and easily reset back to default settings quickly.