The pages like "about" will be created automatically when a new blog is created. Likewise I need some other pages which should appear automatically when a blog is created under my multisites.

How can I configure the default pages to be created with a new blog under a multisite?

For ex.: If I have a multisite on example.com. Every blog created under this site should have Home, About, My store, My address.

  • 3
    I actually plan on creating a plugin for this. I am planning to define an easily created format for saving and restoring a post to and from a text file and to even create a post in this format by hand by a non-technical person. But I haven't started work on it yet so I can only tell you about what I envision it will be. In the mean time, @kevtrout has a reasonable solution below. Commented Aug 30, 2010 at 18:58
  • @MikeSchinkel: I suppose it would be nice to A) Create template versions of each default page as a standard page, and B) Define those pages as 'default' using a form in the admin section. When an 'MU-style' blog is activated, the template pages are copied to that blog account. Seems like a great idea for the Multi-site uses of WP. My needs in the past have required default content to appear in the write-post textarea. Never did figure it out...new question perhaps?
    – kevtrout
    Commented Aug 30, 2010 at 20:01
  • @kevtrout - write-post textarea? You mean post_content? If not then yeah, a new question. That's what SE is here for. :) Commented Aug 31, 2010 at 9:23

2 Answers 2


I recommend creating a function in your functions.php file that ties to the action hook activate_blog. Use the WordPress functions get_pages() to see if your default pages exist. If they do not, create them with wp_insert_post.


function my_default_pages(){
    $default_pages = array('About','Home','My Store','My Address');
    $existing_pages = get_pages();

    foreach($existing_pages as $page){
        $temp[] = $page->post_title;

    $pages_to_create = array_diff($default_pages,$temp);

    foreach($pages_to_create as $new_page_title){

            // Create post object
            $my_post = array();
            $my_post['post_title'] = $new_page_title;
            $my_post['post_content'] = 'This is my '.$new_page_title.' page.';
            $my_post['post_status'] = 'publish';
            $my_post['post_type'] = 'page';

            // Insert the post into the database
            $result = wp_insert_post( $my_post );


To test this function on your own site, try setting the hook to wp_head. It will run on each page load and insert the pages that don't exist, with the content in $my_post['post_content']. *Does the 'activate_blog' hook run when blogs are created in a multi-site context? I don't know.*

Refer to the codex page for wp_insert_post that I linked to for the complete list of default parameters available.

  • I have grabbed the code you have given and pasted in my theme's functions.php with out any changes. And later I have created a new site to check whether it is created with newly added pages. But unfortunately I have not find any changes in new site or in main site. I think I committed mistake some where .
    – user391
    Commented Sep 3, 2010 at 11:06
  • Follow my recommendation to set the hook to wp_head above to test whether the code is working for you. Then look into exactly when the 'activate_blog' hook fires.
    – kevtrout
    Commented Sep 3, 2010 at 11:31
  • 1
    Sorry ! I am still unable to follow where to use wp_head and how to proceed .I am newer to wordpress.I know a little bit of php and not much familiar to coding .
    – user391
    Commented Sep 3, 2010 at 14:18
  • Change add_action('activate_blog','my_default_pages');, to add_action('wp_head','my_default_pages');. Then go read about action and filter hooks: codex.wordpress.org/Plugin_API/Action_Reference. In the end, you'll need to find the hook that runs when a new blog is activated, so that pages will be created at that time. I believe that hook is activate_blog but the documentation for it in the codex is sparse. Try googling for more info. I suggest using wp_head just to test the function above. When you know it works and have found the right hook to use, use that instead.
    – kevtrout
    Commented Sep 3, 2010 at 20:18
  • It worked for me when I added 'wp_head' instead of 'activate_blog' . This is what I did : I have tried adding add_action('wp_head','my_default_pages'); Then I have created a new sub-site. The pages 'About','Home','My Store','My Address' were automatically created .
    – user391
    Commented Sep 4, 2010 at 8:42

use "wpmu_activate_blog" instead of "activate_blog". it worked for me. thanks


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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