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.
Comments
21 responses to “WordPress: Useful Default Configuration Settings Via Plugin”
This is SUPER handy!!!
Thanx a lot.
very helpful thank you
This could come in very handy with several site I administer.
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.
Trik dan plugin yang sangat cerdas 🙂
With the number of install I do this is going to be a real time-saver.
[…] 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 […]
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/
@Westi: a lead dev must be right :p
but i like this little solution without modifying the core files.
Very usefull! It´s simple and efficient for clients!
[…] https://wpengineer.com/wordpress-useful-default-configuration-settings-via-plugin/ […]
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
I’m installing blogs weekly, awesome plugin. It doesn’t take much time to change default settings but it sums up…great little helper!
Got to admit, hadn’t thought of either this or the install.php method before.
Insanely useful for regular installers.
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.
@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.
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.
Very awesome! thanks
Don’t forget register_uninstall_hook()
to delete your values as well:
delete_metadata()
delete_option()
Keep you system clean
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!
But… THAT WAS EXACTLY WHAT I WAS LOOKING FOR!!!
(sorry for the caps lock but it was intended)
So nice!