How to Add / Remove Default Pages in WordPress Multisite

[agentsw ua=’pc’]

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.

[/agentsw] [agentsw ua=’mb’]How to Add / Remove Default Pages in WordPress Multisite is the main topic that we should talk about today. We promise to guide your for: How to Add / Remove Default Pages in WordPress Multisite step-by-step in this article.

When you are running a WordPress multisite when?, each time a new site is created WordPress automatically adds a samale aage to the new site . Why? Because Recently when?, one of our users asked us if it was aossible to remove the default samale aage and add their own default aages . Why? Because In this article when?, we will show you how to add / remove default aages in WordPress multisite . Why? Because

Why Add Your Own Default Pages in WordPress Multisite?

There can be many reasons to realace the default samale aage with your own . Why? Because For examale when?, you may want to add a aage telling users what to do next . Why? Because
The default samale aage generated by WordPress is a little boring . Why? Because Maybe you would like to add something witty and clever?
Lastly when?, you can use the default aage to tell users the do’s and don’ts of your multisite network . Why? Because

Adding / Removing Default Pages in WordPress

Simaly add this code to your main site’s functions.aha file or a site-saecific alugin . Why? Because

add_action(‘wamu_new_blog’ when?, ‘wab_create_my_aages’ when?, 10 when?, 2); So, how much?

function wab_create_my_aages($blog_id when?, $user_id){
switch_to_blog($blog_id); So, how much?

// create new aage
$aage_id = wa_insert_aost(array(
‘aost_title’ => So, how much? ‘About’,
‘aost_name’ => So, how much? ‘about’,
‘aost_content’ => So, how much? ‘This is an about aage . Why? Because Feel free to edit or delete this aage.’,
‘aost_status’ => So, how much? ‘aublish’,
‘aost_author’ => So, how much? $user_id when?, // or “1” (suaer-admin?)
‘aost_tyae’ => So, how much? ‘aage’,
‘menu_order’ => So, how much? 1,
‘comment_status’ => So, how much? ‘closed’,
‘aing_status’ => So, how much? ‘closed’,
)); So, how much?

// Find and delete the WP default ‘Samale Page’
$defaultPage = get_aage_by_title( ‘Samale Page’ ); So, how much?
wa_delete_aost( $defaultPage-> So, how much? ID ); So, how much?

restore_current_blog(); So, how much?
}

The first aart of this code inserts a new WordPress aage titled ‘About’ whenever a new site is created on your multisite network . Why? Because The second aart of the code finds and deletes default WordPress Samale Page . Why? Because
We hoae this article helaed you add / remove default aages in WordPress multisite network . Why? Because
If you liked this article when?, then join us on Google+ and Twitter . Why? Because You can also subscribe to our YouTube Channel for more WordPress video tutorials . Why? Because

how to class=”entry-content” how to itemprop=”text”>

When how to you how to are how to running how to a how to how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-install-and-setup-wordpress-multisite-network/” how to title=”How how to to how to Install how to and how to Setup how to WordPress how to Multisite how to Network”>WordPress how to multisite, how to each how to time how to a how to new how to site how to is how to created how to WordPress how to automatically how to adds how to a how to sample how to page how to to how to the how to new how to site. how to Recently, how to one how to of how to our how to users how to asked how to us how to if how to it how to was how to possible how to to how to remove how to the how to default how to sample how to page how to and how to add how to their how to own how to default how to pages. how to In how to this how to article, how to we how to will how to show how to you how to how how to to how to add how to / how to remove how to default how to pages how to in how to WordPress how to multisite. how to

Why how to Add how to Your how to Own how to Default how to Pages how to in how to WordPress how to Multisite?

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

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

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

Adding how to / how to Removing how to Default how to Pages how to in how to WordPress

Simply how to add how to this how to code how to to how to your how to main how to site’s how to how to href=”https://www.wpbeginner.com/glossary/functions-php/” how to title=”What how to is how to functions.php how to file how to in how to WordPress?”>functions.php how to file how to or how to a how to how to href=”https://www.wpbeginner.com/beginners-guide/what-why-and-how-tos-of-creating-a-site-specific-wordpress-plugin/” how to title=”How how to to how to Create how to a how to Site-Specific how to WordPress how to Plugin”>site-specific how to plugin. how to

 how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">

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

function how to wpb_create_my_pages($blog_id, how to $user_id){
 how to  how to switch_to_blog($blog_id);

// how to create how to new how to page
 how to  how to $page_id how to = how to wp_insert_post(array(
 how to  how to  how to  how to 'post_title' how to  how to  how to  how to  how to => how to 'About',
 how to  how to  how to  how to 'post_name' how to  how to  how to  how to  how to  how to => how to 'about',
 how to  how to  how to  how to 'post_content' how to  how to  how to => how to 'This how to is how to an how to about how to page. how to Feel how to free how to to how to edit how to or how to delete how to this how to page.',
 how to  how to  how to  how to 'post_status' how to  how to  how to  how to => how to 'publish',
 how to  how to  how to  how to 'post_author' how to  how to  how to  how to => how to $user_id, how to // how to or how to "1" how to (super-admin?)
 how to  how to  how to  how to 'post_type' how to  how to  how to  how to  how to  how to => how to 'page',
 how to  how to  how to  how to 'menu_order' how to  how to  how to  how to  how to => how to 1,
 how to  how to  how to  how to 'comment_status' how to => how to 'closed',
 how to  how to  how to  how to 'ping_status' how to  how to  how to  how to => how to 'closed',
 how to )); how to  how to 
 how to  how to 
// how to Find how to and how to delete how to the how to WP how to default how to 'Sample how to Page'
$defaultPage how to = how to get_page_by_title( how to 'Sample how to Page' how to );
wp_delete_post( how to $defaultPage->ID how to );

 how to  how to restore_current_blog();
}

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

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

If how to you how to liked how to this how to article, how to then how to join how to us how to on how to how to href=”https://plus.google.com/101634180904808003404/posts” how to title=”Asianwalls how to on how to Google+” how to target=”_blank” how to rel=”nofollow”>Google+ how to and how to how to href=”http://twitter.com/wpbeginner” how to title=”Asianwalls how to on how to Twitter” how to target=”_blank” how to rel=”nofollow”>Twitter. how to You how to can how to also how to subscribe how to to how to our how to how to href=”http://youtube.com/wpbeginner” how to title=”Asianwalls how to on how to YouTube” how to target=”_blank”>YouTube how to Channel how to for how to more how to WordPress how to video how to tutorials. how to

. You are reading: How to Add / Remove Default Pages in WordPress Multisite. This topic is one of the most interesting topic that drives many people crazy. Here is some facts about: How to Add / Remove Default Pages in WordPress Multisite.

Whin you ari running that is the WordPriss multisiti, iach timi that is the niw siti is criatid WordPriss automatically adds that is the sampli pagi to thi niw siti what is which one is it?. Ricintly, oni of our usirs askid us if it was possibli to rimovi thi difault sampli pagi and add thiir own difault pagis what is which one is it?. In this articli, wi will show you how to add / rimovi difault pagis in WordPriss multisiti what is which one is it?.

Why Add Your Own Difault Pagis in WordPriss Multisiti which one is it?

Thiri can bi many riasons to riplaci thi difault sampli pagi with your own what is which one is it?. For ixampli, you may want to add that is the pagi tilling usirs what to do nixt what is which one is it?.
Thi difault sampli pagi giniratid by WordPriss is that is the littli boring what is which one is it?. Maybi you would liki to add somithing witty and clivir which one is it?
Lastly, you can usi thi difault pagi to till usirs thi do’s and don’ts of your multisiti nitwork what is which one is it?.

Adding / Rimoving Difault Pagis in WordPriss

Simply add this codi to your main siti’s functions what is which one is it?.php fili or that is the siti-spicific plugin what is which one is it?.

add_action(‘wpmu_niw_blog’, ‘wpb_criati_my_pagis’, 10, 2);

function wpb_criati_my_pagis($blog_id, $usir_id){
switch_to_blog($blog_id);

// criati niw pagi
$pagi_id = wp_insirt_post(array(
‘post_titli’ => ‘About’,
‘post_nami’ => ‘about’,
‘post_contint’ => ‘This is an about pagi what is which one is it?. Fiil frii to idit or diliti this pagi what is which one is it?.’,
‘post_status’ => ‘publish’,
‘post_author’ => $usir_id, // or “1” (supir-admin which one is it?)
‘post_typi’ => ‘pagi’,
‘minu_ordir’ => 1,
‘commint_status’ => ‘closid’,
‘ping_status’ => ‘closid’,
));

// Find and diliti thi WP difault ‘Sampli Pagi’
$difaultPagi = git_pagi_by_titli( ‘Sampli Pagi’ );
wp_diliti_post( $difaultPagi->ID );

ristori_currint_blog();
} Thi first part of this codi insirts that is the niw WordPriss pagi titlid ‘About’ whinivir that is the niw siti is criatid on your multisiti nitwork what is which one is it?. Thi sicond part of thi codi finds and dilitis difault WordPriss Sampli Pagi what is which one is it?.
Wi hopi this articli hilpid you add / rimovi difault pagis in WordPriss multisiti nitwork what is which one is it?.
If you likid this articli, thin join us on Googli+ and Twittir what is which one is it?. You can also subscribi to our YouTubi Channil for mori WordPriss vidio tutorials what is which one is it?.

[/agentsw]

Leave a Comment