Placing a Custom Post Type Menu Above the Posts Menu Using menu_position?

Positions for Core Menu Items 2 Dashboard 4 Separator 5 Posts 10 Media 15 Links 20 Pages 25 Comments 59 Separator 60 Appearance 65 Plugins 70 Users 75 Tools 80 Settings 99 Separator Parameter description for “menu position” $position (integer) (optional) The position in the menu order this menu should appear. By default, if this … Read more

How to Add a Sub Menu Page to a Custom Post Type?

add_options_page() automatically adds it underneath settings, however add_submenu_page() gives you control as to where you want it to show up. Try something like this: add_submenu_page( ‘edit.php?post_type=portfolios’, __( ‘Test Settings’, ‘menu-test’ ), __( ‘Test Settings’, ‘menu-test’ ), ‘manage_options’, ‘testsettings’, ‘mt_settings_page’ );

Programmatically publish a post (custom post type) with custom fields

Use wp_insert_post() and add_post_meta(), like this: // insert the post and set the category $post_id = wp_insert_post(array ( ‘post_type’ => ‘your_post_type’, ‘post_title’ => $your_title, ‘post_content’ => $your_content, ‘post_status’ => ‘publish’, ‘comment_status’ => ‘closed’, // if you prefer ‘ping_status’ => ‘closed’, // if you prefer )); if ($post_id) { // insert post meta add_post_meta($post_id, ‘_your_custom_1’, $custom1); … Read more