简体   繁体   中英

Wordpress multisite - Default Posts Page

I am trying to set the default page for blog posts when a new site is created in wordpress multisite. I have no problem setting a default static page by running the following but can't figure it out for setting the default posts page.

Thanks in advance

Set Default Static Page as is_front_page:

add_action( 'wpmu_new_blog', 'process_extra_field_on_blog_signup', 10, 6 );

function process_extra_field_on_blog_signup( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
switch_to_blog($blog_id);
$homepage = get_page_by_title( 'Home' );   
if ( $homepage )
{
    update_blog_option( $blog_id, 'page_on_front', $homepage->ID );
    update_blog_option( $blog_id, 'show_on_front', 'page' );
}
restore_current_blog();
}

解:

update_blog_option( $blog_id, 'page_for_posts', $blogpage->ID );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM