Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Add / Remove Default Pages in WordPress Multisite

When you are running a WordPress multisite, each time a new site is created WordPress automatically adds a sample page to the new site. Recently, one of our users asked us if it was possible to remove the default sample page and add their own default pages. In this article, we will show you how to add / remove default pages in WordPress multisite.

Why Add Your Own Default Pages in WordPress Multisite?

There can be many reasons to replace the default sample page with your own. For example, you may want to add a page telling users what to do next.

The default sample page generated by WordPress is a little boring. Maybe you would like to add something witty and clever?

Lastly, you can use the default page to tell users the do’s and don’ts of your multisite network.

Adding / Removing Default Pages in WordPress

Simply add this code to your main site’s functions.php file or a site-specific plugin.


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

function wpb_create_my_pages($blog_id, $user_id){
  switch_to_blog($blog_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 );

  restore_current_blog();
}

The first part of this code inserts a new WordPress page titled ‘About’ whenever a new site is created on your multisite network. The second part of the code finds and deletes default WordPress Sample Page.

We hope this article helped you add / remove default pages in WordPress multisite network.

If you liked this article, then join us on Google+ and Twitter. You can also subscribe to our YouTube Channel for more WordPress video tutorials.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

8 CommentsLeave a Reply

  1. Syed Balkhi

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Maxwell

    Don’t forget handle other languages too: in $defaultPage = get_page_by_title( ‘Sample Page’ ); , use:

    $defaultPage = get_page_by_title( __(‘Sample Page’) );

    This way, the Sample Page word will be translated and the page will be found in any language.

  3. ali

    thank you.
    it solved my problem. :)

    • shamim

      Hi WPBeginner i can’t remove default page Home
      i am using tweenty twelve theme.. pls help me

  4. sleon

    what do you mean about, “Simply add this code to your main site’s functions.php” in the theme functions.php?

  5. iwan

    how to removing with page more than one,for example page title(‘Sample page’,’MY product’,’Contact ‘)

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.