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;
}
If you do not specify a title, but you specify the post_status as publish, will this automatically create a slug for you?
It certainly will! Check the source code for wp_insert_post()
.