当你create a new site with multisite WP不会自动更改上下文。因此,您的操作将添加到当前站点,而不是新站点。你必须先切换。像这样:
add_action (\'wpmu_new_blog\', \'wpse296303_delete_wordpress_defaults\', 100, 1);
function wpse296303_delete_wordpress_defaults ($blog_id, $user_id, $domain, $path, $site_id, $meta) {
// Switch to the newly created blog
switch_to_blog ($blog_id);
// Delete \'Hello World!\' post
wp_delete_post (1, true);
// Delete \'Sample page\' page
wp_delete_post (2, true);
// Delete \'Sample comment\' page
wp_delete_comment (1, true)
}
我不确定默认注释的ID是否为1,因此您必须进行检查。