Is it possible to stop WP from creating the "Sample Page" and "Hello World!" post when creating a new blog?
2 Answers
If you're using Multisite
The accepted answer is destructive in that it cancels all other set-up items in the overridden function. A less destructive way to do it for multisite installs is to delete the default content during new blog creation by hooking in to wpmu_new_blog
add_action( 'wpmu_new_blog', 'delete_wordpress_defaults', 100, 1 );
function delete_wordpress_defaults(){
// 'Hello World!' post
wp_delete_post( 1, true );
// 'Sample page' page
wp_delete_post( 2, true );
}
Create a file install.php
in your wp-content
directory. In that file you declare the wp_install_defaults()
function. If you just leave that function empty no default categories, links, posts or pages will be created.
The default (pluggable) wp_install_defaults()
function can be found in wp-admin/includes/upgrade.php
.
-
1Thank you! Do you have an idea to solve the problem with WP Multisite? After adding the install.php in the wp-content directory I get a 500 Error when creating new site. Commented Nov 7, 2012 at 18:55
-
Sorry, ignore my comment—the 500 Error was caused by something else! Also works for Multisite! Commented Nov 7, 2012 at 19:22
-
This will also cancel the creation of the 'Uncategorized' category, and a host of other settings. check the function at the following link to see what exactly you'll be overriding: core.trac.wordpress.org/browser/tags/4.8/src/wp-admin/includes/…– StevenCommented Jul 4, 2017 at 15:04
-
Please see my answer below for a less destructive way of doing this for multisite installs wordpress.stackexchange.com/a/272252/13118– StevenCommented Jul 4, 2017 at 15:28