Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm creating a multisite network and I am looking for a way to have it so new blogs that are created have a couple of standard pages set up automatically.

The purpose of these pages will be to display universal membership options and other info that I want each site to display.

So, for example, I want each new site to have a "Join" page and an "About this Network" page, and I don't want to have to manually set up the pages and their custom templates.

I'm using Twentyeleven as my child theme base and customizing a specific theme to be used by each of the newly created sub blogs users.

I guess a part of this question is: is it possible to hardcode pages into a Wordpress theme?

Thanks very much.

JW

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Hook into wpmu_new_blog and create your 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 this Network')) return;

  // create each page
  $page_id = wp_insert_post(array(
    'post_title'     => 'About this Network',
    'post_name'      => 'about-this-network',
    'post_content'   => 'Co za asy...',
    'post_status'    => 'publish',
    'post_author'    => $user_id, // or "1" (super-admin?)
    'post_type'      => 'page',
    'menu_order'     => 666,
    'comment_status' => 'closed',
    'ping_status'    => 'closed',
     // + see: http://codex.wordpress.org/Function_Reference/wp_insert_post
  ));  

  restore_current_blog();
}

You could put this inside a plugin that you network activate, or a must-use plugin, this way they are available in all themes.

Another way is to use template_redirect hook and include your own template files

share|improve this answer
    
+1 good answer. I'd add that the OP should use an input array of $pages and then loop through if he'd need more than one page. –  kaiser Sep 15 '11 at 18:03
    
@kaiser how do you use the array of pages to have multiple pages? –  mygm26 Sep 9 '13 at 3:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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