2 Different Custom Post Types in Submenu

i have register 2 custom post types within my plugin one of them is shown in the left admin bar, the second i wouldn’t show so i have set the “show_ui” to false.

Is it possible to add the second post type to the menu of the first post type?

Read More

first post type:

$args = array(
  'labels' => $labels,
  'public' => true,
  'has_archive' => false,
  'menu_position' => 100,
  'supports' => array( 'title', 'editor', 'custom-fields', 'thumbnail' ),
  'menu_icon' => plugins_url( 'assets/img/small1.png', __FILE__ ),
  'rewrite' => array('slug' => 'screenshots', 'with_front' => true)
);

register_post_type( 'screenshots', $args );

second post type:

$args = array(
  'show_ui' => false,
  'labels' => $labels,
  'public' => true,
  'has_archive' => false,
  //'menu_position' => 100,
  'supports' => array( 'title', 'editor', 'custom-fields', 'thumbnail' ),
  //'menu_icon' => plugins_url( 'assets/img/small2.png', __FILE__ ),
  'rewrite' => array('slug' => 'deal', 'with_front' => true)
);

register_post_type( 'deals', $args );

I try to add the second post type with:

add_submenu_page( 'edit.php?post_type=deals', __('Deal', $this->var_sTextdomain), __('Deal', $this->var_sTextdomain), 'manage_options', 'my-deal', array(&$this, 'deal_page') );

What can i do to add it to the first post type at the end?

regards

Related posts

1 comment

  1. A CPT has a parameter called show_in_menu to add it to a specific menu.

    You must set you CPT to 'public' => true

    Then in your deals $args (it’s unclear which one you wanted added ) add something like,

    'show_in_menu' => 'edit.php?post_type=screenshots'
    

    You can then adjust it accordingly.

Comments are closed.