WordPress.org

Support

Support » Plugins and Hacks » Theme My Login » Remove Default Pages created on all multisites

Remove Default Pages created on all multisites

Viewing 2 replies - 1 through 2 (of 2 total)
  • I figured out how to add default pages for multisites, but how do I remove the TML default pages?

    add_action('wpmu_new_blog', 'create_my_pages', 10, 2);
    
    function create_my_pages($blog_id, $user_id){
      switch_to_blog($blog_id);
    
      // not really need, new blogs shouldn't have any content
      if(get_page_by_title('About')) return;
    
      // create each page
      $page_id = wp_insert_post(array(
        'post_title'     => 'About',
        'post_name'      => 'about',
        'post_content'   => 'This is your about page',
        'post_status'    => 'publish',
        'post_author'    => $user_id, // or "1" (super-admin?)
        'post_type'      => 'page',
        'menu_order'     => 1,
        'comment_status' => 'closed',
        'ping_status'    => 'closed',
         // + see: http://codex.wordpress.org/Function_Reference/wp_insert_post
      ));  
    
      restore_current_blog();
    }

    To remove the “Sample Page” that WP creates when each new multisite site is created, add the following to your code block above. Add it just before the restore_current_blog() tag.

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

    This will delete the page with the title “Sample Page”.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Remove Default Pages created on all multisites’ is closed to new replies.
Skip to toolbar