Support » Developing with WordPress » CPT inside of CPT menu

  • Resolved Cezar Ayran

    (@ayrancd)


    Is it possible to add a CPT inside of another CPT menu?

    I mean..

    I have CPT “A” with many taxonomies..

    I’d like to create another CPT and instead of having a parent menu in the nav bar I’d like to add this new CPT under the CPT “A” options in the nav bar not in the post

Viewing 4 replies - 1 through 4 (of 4 total)
  • I don’t know what you mean by “options in the nav bar”.
    Are you using a plugin to create the CPT? Does the plugin create the nav bar?

    When you create a WordPress menu, you can put whatever you want in it, in any order or nesting.
    But it sounds like a confusion of post type and taxonomy. Post types contain content. Taxonomies are labels to organize the content.

    Thread Starter Cezar Ayran

    (@ayrancd)

    Hi Joy,

    Let me explain. Anytime I create a new CPT it adds a new item to the navigation bar. If I create a taxonomy I can set that taxonomy to a Post Type and it will be added as a child item under the post type.

    What I am trying to say is: I want to add a different post type under a specific post type so instead of having a new menu item this new post type item would be added under whatever Post Type I want.

    Now I have:

    Post Type A
    Tax 1
    Tax 2

    Post Type B
    Tax 1
    Tax 2

    I want…

    Post Type A
    Tax 1
    Tax 2
    Post Type B

    Below is the Post Type B code:

    function pt_coupons(){
        register_post_type('coupons',
          array(
              'labels' => array('name' => __('SS Coupons'), 'singular_name' => __('SS Coupons')),
                'public' => false,
               'publicly_queryable' => false,
               'has_archive' => false,
               'with_front' => false,
               'exclude_from_search' => true, 
               'rewrite' => false,
               'show_in_nav_menus' => false,
               'show_ui' => true,
               'supports' => array('title'),
                'menu_icon' => 'data:image/svg+xml;base64,'.base64_encode('<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="47.7px" height="32.8px" viewBox="0 0 47.7 32.8" enable-background="new 0 0 47.7 32.8" xml:space="preserve"><path fill="#FCFCFC" d="M48,30.7c0,0,0,0.1,0,0.1c0,0,0.1,0,0.1,0C48.1,30.8,48.1,30.8,48,30.7C48.1,30.8,48,30.7,48,30.7z"/><g><path fill="#0B0B0B" d="M44.7,29.1c-7-3.4-13.9-6.8-21.1-9.7c-5.3-2.2-10.7-4.3-16.4-5.3c-1.3-0.2-2.5-0.3-3.8-0.2
        c-1.7,0.2-2.5,0.9-2.8,2.6c-0.5,0-0.2-0.6-0.5-0.6c0-0.8,0-1.6,0-2.4c0.9-1.5,2.4-2,4.1-2c3.6,0,7,1.2,10.4,2.4
        c9.8,3.6,18.9,8.5,28,13.4c0.8,0.4,1.5,0.9,2.3,1.3C44.8,28.8,44.8,29,44.7,29.1z"/><path fill="#020202" d="M10.7,11.2c2.8-6.6,7.5-10.5,14.4-11.1c7.1-0.6,12.7,2.3,16.2,8.6c3.2,5.7,2.8,11.4-0.4,17 c-5.3-3.3-10.4-6.6-15.6-9.7c-3-1.9-6.1-3.6-9.5-4.8C14.2,10.6,12.6,10.2,10.7,11.2z"/><path fill="#040404" d="M11.2,22.1c8.8,1.2,17.1,4.2,25.4,7.2C27.7,36.4,14.6,32.1,11.2,22.1z"/><path fill="#0C0C0C" d="M47.2,31.5c-0.5,0.2-0.9-0.2-1.4-0.3c-9.3-3.7-18.6-7.3-28.3-9.6c-2.9-0.7-5.9-1.3-8.9-1.2
        c-1.8,0.1-3.5,0.5-4.2,2.6c-0.9-2.9,0.1-4.4,3.1-4.7c3.7-0.3,7.2,0.6,10.6,1.6c9.7,2.8,18.9,6.9,28.1,11c0.3,0.1,0.6,0.3,0.9,0.4
        C47.2,31.4,47.2,31.4,47.2,31.5z"/></g><path d="M44.7,29.1c0-0.2,0-0.3,0-0.5c1,0.5,2,1,2.9,1.6c-0.1,0.1-0.1,0.2-0.2,0.3C46.6,30.2,45.6,29.7,44.7,29.1z"/><path fill="#FAFAFA" d="M48,30.7C48,30.7,48.1,30.8,48,30.7c0.1,0.1,0.1,0.1,0.1,0.1c0,0-0.1,0-0.1,0C48,30.8,48,30.8,48,30.7z"/></svg>')
          )
        );
    }
    add_action('init', 'pt_coupons');

    I don’t see why you would want that, but go to https://developer.wordpress.org/reference/functions/register_post_type/ and read carefully the description of the ‘show_in_menu’ parameter.

    Thread Starter Cezar Ayran

    (@ayrancd)

    PERFEEEEEEEECCCT

    'show_in_menu' => 'edit.php?post_type=slabs',

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘CPT inside of CPT menu’ is closed to new replies.