“The”;wpmu\\u new\\u博客;钩子已被弃用!相反,您应该使用;wp\\U initialize\\U site“wp\\U initialize\\U site”;钩出于某种原因,Per Søderlind建议在中使用高于100的优先级this post.
其余的都差不多。所做的唯一更改(也采纳了佩尔·瑟琳德所做的帖子的建议)是将$blog\\u id更改为$new\\u站点->;blog\\u id。仅使用$blog\\u id对我不起作用。
还有,重要的细节。我将这段代码作为mu插件。
add_action(\'wp_initialize_site\', \'wpb_create_my_pages\', 910, 1);
function wpb_create_my_pages(WP_Site $new_site){
switch_to_blog($new_site->blog_id);
// create new page
$page_id = wp_insert_post(array(
\'post_title\' => \'About\',
\'post_name\' => \'about\',
\'post_content\' => \'Page content goes in here\',
\'post_status\' => \'publish\',
\'post_author\' => 1,
\'post_type\' => \'page\',
\'menu_order\' => 1,
\'comment_status\' => \'closed\',
\'ping_status\' => \'closed\',
));
// Find and delete the WP default \'Sample Page\'
$defaultPage = get_page_by_title( \'Sample Page\' );
wp_delete_post( $defaultPage->ID );
restore_current_blog();
}
希望这能奏效!