Skip to content

Instantly share code, notes, and snippets.

@jonathonklem
Created March 29, 2016 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathonklem/03ca78eb8272f01d7835 to your computer and use it in GitHub Desktop.
Save jonathonklem/03ca78eb8272f01d7835 to your computer and use it in GitHub Desktop.
add_action('wpmu_new_blog', 'wpb_create_my_pages', 10, 2);
function wpb_create_my_pages($blog_id, $user_id){
switch_to_blog($blog_id);
// create new page
$page_id = wp_insert_post(array(
'post_title' => 'Home',
'post_name' => 'home',
'post_content' => 'Welcome to our shop.',
'post_status' => 'publish',
'post_author' => $user_id, // or "1" (super-admin?)
'post_type' => 'page',
'menu_order' => 1,
'comment_status' => 'closed',
'ping_status' => 'closed',
));
update_option( 'page_on_front', $page_id );
update_option( 'show_on_front', 'page' );
// Find and delete the WP default 'Sample Page'
$defaultPage = get_page_by_title( 'Sample Page' );
wp_delete_post( $defaultPage->ID );
wp_insert_post(array(
'post_title' => 'About Us',
'post_name' => 'about-us',
'post_content' => 'Add information about your group here.',
'post_status' => 'publish',
'post_author' => $user_id, // or "1" (super-admin?)
'post_type' => 'page',
'menu_order' => 1,
'comment_status' => 'closed',
'ping_status' => 'closed',
));
wp_insert_post(array(
'post_title' => 'Contact Us',
'post_name' => 'contact-us',
'post_content' => 'Add information about contacting you here.',
'post_status' => 'publish',
'post_author' => $user_id, // or "1" (super-admin?)
'post_type' => 'page',
'menu_order' => 1,
'comment_status' => 'closed',
'ping_status' => 'closed',
));
restore_current_blog();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment