add_action( \'admin_menu\', \'av_subscribe_create_menu\' );
function av_subscribe_create_menu()
{
$hook = add_menu_page(
\'Add Comment Feed\',
\'Add Comment Feed\',
\'manage_options\',
\'av-create-feed\', // Don\'t use __FILE__ as the slug, keep it short \'n sweet!
\'__return_true\' // We need a callback otherwise WP won\'t properly handle the page, though it\'s never seen
);
if ( $hook ) // Current user has the right caps
add_action( "load-$hook", \'av_subscribe_create_feed_page\' ); // This runs before header output
}
function av_subscribe_create_feed_page()
{
$page_id = wp_insert_post( array(
\'post_status\' => \'publish\',
\'post_parent\' => 13570,
\'post_title\' => \'My Title\',
\'post_type\' => \'page\',
));
if ( $edit_url = get_edit_post_link( $page_id, \'raw\' ) )
wp_redirect( $edit_url );
else
wp_redirect( admin_url( "edit.php?post_type=page" ) ); // Fallback
exit;
}
如果未指定标题,但将post\\u状态指定为publish,这会自动为您创建slug吗?
当然会的!检查源代码wp_insert_post()
.