多站点,要么更改Sample-Page名称,要么创建新页面 时间:2012-04-26 作者:Dean Elliott 每次用户在WP multisite上创建一个新博客时,有没有办法更改默认示例页面的名称或完全创建一个新页面? 1 个回复 SO网友:kaiser 核心功能wp_insert_post() 可以添加(&E)创建帖子(每种帖子类型)。插件/* Plugin Name: Add default blog pages Plugin URl: http://goo.gl/5e1DC Author: Kaiser Author URI: http://unserkaiser.com */ /** * Default Blog pages - used to define all default pages. * Adjust this to your needs: * For a full example of what you can define for every page, take a look at * @link http://codex.wordpress.org/Function_Reference/wp_insert_post * @return array */ function wpse50318_default_blog_pages() { return array( array( \'post_title\' => \'About\' ), array( \'post_title\' => \'Contact\' ) ); } /** * Adds Default Blog pages * @return void */ function wpse50318_add_default_pages_to_blog() { foreach ( get_pages() as $page ) $existing_pages[] = $page->post_title; // Get only non existing pages: $new_pages = array_diff( $GLOBALS[\'$wpse50318_default_blog_pages\'], $existing_pages); // Loop over the non existing & add them foreach( $new_pages as $page ) { // Create post object $page[\'post_status\'] = \'publish\'; $page[\'post_type\'] = \'page\'; // Insert the post into the database wp_insert_post( $page ); } } add_action( \'activate_blog\', \'wpse50318_add_default_pages_to_blog\' ); 结束 文章导航