Latest Tech and Tips

How to Add/ Remove Default Pages in WordPress Multisite

11

When you are running a WordPress multisite, each time a brand-new website is produced WordPress immediately includes an example web page to the brand-new website. Recently, among our customers asked us if it was feasible to remove the default example web page and also add their very own default pages. In this write-up, we will certainly reveal you how to add/ remove default pages in WordPress multisite.

Why Add Your Own Default Pages in WordPress Multisite?

There can be numerous factors to change the default example web page with your very own. For instance, you might desire to add a web page informing customers what to do following.

The default example web page created by WordPress is a little boring. Maybe you would certainly such as to add something amusing and also smart?

Lastly, you can utilize the default web page to inform customers the do’s and also do n’ts of your multisite network.

Adding/ Removing Default Pages in WordPress

Simply add this code to your major website’s functions.php data or a site-specific plugin.


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

feature wpb_create_my_pages($ blog_id, $user_id) {
switch_to_blog($ blog_id);.

// produce brand-new web page.
$ page_id = wp_insert_post( range(.
' post_title' => > 'About',.
' post_name' => > 'regarding',.
' post_content' => > 'This is a regarding web page. Feel cost-free to edit or remove this web page.',.
' post_status' => > 'release',.
' post_author' => > $user_id,// or "1" (super-admin?).
' post_type' => > 'web page',.
' menu_order' => > 1,.
' comment_status' => > 'shut',.
' ping_status' => > 'shut',.
));.

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

restore_current_blog();.
}

The initial component of this code inserts a brand-new WordPress web page entitled ‘About’ whenever a brand-new website is produced on your multisite network. The 2nd component of the code discovers and also erases defaultWordPress Sample Page

We wish this write-up assisted you add/ remove default pages in WordPress multisite network.

If you liked this write-up, after that join us on Google+ and alsoTwitter You can likewise subscribe to our YouTube Channel for even more WordPress video clip tutorials.

.