2

I created a multisite and my question is as followed:

Im trying to display a default static page for each new site. So when they create a new site, they automatically get a default page I made. This is the only page they need and have controle over. This page has only widgetized area's in it so that the site-admin can add content by adding widgets into the widget area's. They dont have access to create a post or page themselves.

By adding a piece of code into wp-admin/includes/upgrade.php the page will be automatically made by WP whenever a new site is made. However, the page isnt connected to the template with the html/php code in it to display the widgets they add. Normally in WP you can create a page and on the right side you can select a template.

Is it clear this far? (even I get confused lol)

So what Im asking is.. is there a way to create a static frontpage for all newly created sites (like test.example.com and test2.example.com) with a template connected to it?

Thanks in advance!!! It would make my day!

2 Answers 2

1

I would recommend waiting until WordPress 3.4 is released. Among other features, it is slated to include the ability to allow Themes to define/declare a static front page. I believe this functionality should suit your needs.

(Note: as of today, WordPress 3.4 just hit Beta 1, and is scheduled for final release in May.)

0

You can hook into the creation of a new multisite blog like this:

add_action('wpmu_new_blog', 'default_settings', 100, 2);
function default_settings($blog_id, $user_id){
    switch_to_blog($blog_id);

    // setup your page here

    restore_current_blog();
}

In that function you would use wp_insert_post to create your page, and then you would set the option used to determine the homepage to the ID of the newly created post

5
  • Somthing like: $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'; ??
    – Furzery
    Commented Apr 4, 2012 at 9:34
  • yeah, though with the insertion call and the closing of the loop etc
    – Tom J Nowell
    Commented Apr 4, 2012 at 9:51
  • Note that you could also use a home.php template
    – Tom J Nowell
    Commented Apr 4, 2012 at 9:51
  • how would that work? (the home.php) I know how to create a custom template-page but I guess thats not what you meanth
    – Furzery
    Commented Apr 4, 2012 at 11:17
  • refer to the template heirarchy, you have index.php front-page.php and home.php home.php is always the homepage unless you choose a page to be the homepage, front-page.php is the frontpage, aka page 1 of an archive shown by index.php, and index.php is the file used if a file isn't found
    – Tom J Nowell
    Commented Apr 4, 2012 at 13:37

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.