Anybody please help me to figure out how to add custom post type in Settings menu (option_page). Basically it is easy for custom admin menu by using:

'show_in_menu' => 'menu-slug'

but i like to add this post type under option page.


You can add custom post type in Settings menu by passing 'options-general.php' value to 'show_in_menu' parameter as shown below

Example : 'show_in_menu' => 'options-general.php'

Full Code :

function codex_custom_init() {
  $labels = array(
'name' => 'Books',
'singular_name' => 'Book',
'add_new' => 'Add New',
'add_new_item' => 'Add New Book',
'edit_item' => 'Edit Book',
'new_item' => 'New Book',
'all_items' => 'All Books',
'view_item' => 'View Book',
'search_items' => 'Search Books',
'not_found' =>  'No books found',
'not_found_in_trash' => 'No books found in Trash', 
'parent_item_colon' => '',
'menu_name' => 'Books'

  $args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true, 
'show_in_menu' => 'options-general.php',
'query_var' => true,
'rewrite' => array( 'slug' => 'book' ),
'capability_type' => 'post',
'has_archive' => true, 
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )

  register_post_type( 'book', $args );
add_action( 'init', 'codex_custom_init' );

For more information refer this page.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.