1

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?

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

1 Answer 1

0

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.

3
  • the menu from the first post type will show but the data from the second not, i have try your answer but the second will not add ...
    – kai lange
    Commented Jul 11, 2013 at 6:43
  • show_ui must also be set to true, please review the docs for show_in_menu codex.wordpress.org/Function_Reference/register_post_type.
    – Wyck
    Commented Jul 11, 2013 at 6:48
  • my fail - it works - it wasn't show at the end :(
    – kai lange
    Commented Jul 11, 2013 at 6:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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