I'm struggling with WordPress Multisite page creation when newly site created. I found some hooks to achieve this but the hook is not responding. Some of the resources I found on stack and other sites are https://stackoverflow.com/questions/40014419/wordpress-multisite-default-page-for-newly-created-site and http://www.wpbeginner.com/wp-tutorials/how-to-add-remove-default-pages-in-wordpress-multisite/

The hook mentioned in these resources not working in my multisite setup.

add_action('wpmu_new_blog', 'wpb_create_my_pages', 10, 2);

function wpb_create_my_pages($blog_id, $user_id){

// create new page
  $page_id = wp_insert_post(array(
    'post_title'     => 'About',
    'post_name'      => 'about',
    'post_content'   => 'This is an about page. Feel free to edit or delete this page.',
    'post_status'    => 'publish',
    'post_author'    => $user_id, // or "1" (super-admin?)
    'post_type'      => 'page',
    'menu_order'     => 1,
    'comment_status' => 'closed',
    'ping_status'    => 'closed',

// Find and delete the WP default 'Sample Page'
$defaultPage = get_page_by_title( 'Sample Page' );
wp_delete_post( $defaultPage->ID );


I'm adding this code in my child theme functions.php file. Any suggestion to fix this issue.

  • Hi. What do you mean by not working? It doesn't create page? Doesn't delete the sample page? Produces fatal error? etc. – Jack Johansson Jun 12 '17 at 16:29
  • @JackJohansson Yes, not creating the page and not deleting the sample page but does not show any error. – CodeBriefly Jun 12 '17 at 17:42
  • Hmm, it appears @Nikolay is right. It must be in your main site's functions.php, or a plugin. – Jack Johansson Jun 12 '17 at 17:50
  • @JackJohansson no luck, I'm trying the same with functions.php file and also with one plugin. – CodeBriefly Jun 12 '17 at 18:14

The code you provided works great on my multisite. I am putting it in a network activated plugin though. Try the same.

  • I'm trying the same, as built one plugin and that plugin is network activated. But no luck. Will you please explain your setup. – CodeBriefly Jun 12 '17 at 18:12
  • @webtuts4u It uses subdomains for subsites, WP 4.8, PHP 5.6.29, I am creating the sites from /wp-admin/network/site-new.php and putting me as the admin of the new site. – Nikolay Jun 12 '17 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.