我希望在使用WP Multisite创建新站点时,在默认情况下添加一个页面。
因此,我有一个创建两个页面的函数:
function my_default_pages() {
$default_pages = array(\'Impress\', \'Contact\');
$existing_pages = get_pages();
foreach($existing_pages as $page) {
$temp[] = $page->post_title;
}
$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\';
// Insert the post into the database
$result = wp_insert_post( $my_post );
}
}
我发现我必须wpmu_new_blog
[1] 创建新站点时激发的操作。add_action(\'wpmu_new_blog\', \'my_default_pages\');
但我不知道如何让两个人一起工作…