• Resolved mehargags

    (@mehargags)


    I managed to install CPT UI and got the Custom POST URL Structure working as desired
    domain/bschool , domain/jobs , domain/engg , domain/medical

    Now I’m only struggling how to assign different “Menu” specific to its respective Custom Post type’s home (archive) page. Like domain/bschool has its own menu, domain/engg has its own specific and so on…

    I installed this plugin Page Specific Menu Items, created 4 Menus and using this plugin assigned them in this order

    Home-Menu (Main Menu) assigned to site’s default home page

    bschool-Menu assigned to Custom post type bschool
    engg-Menu assigned to Custom post type engg
    jobs-Menu assigned to Custom post type jobs
    Medical-Menu assigned to Custom post type medical

    But it doesn’t seem to work. I see the Home-Menu (Main Menu) on inside custom post type home pages (URLs stated above) the Readme for the plugin says something the problem can be if the theme overides ‘hide_this_item’ but I’m not sure.

    Any tips how to get custom Menu specific to each post type’s page ?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    This is going to be nothing specific to CPTUI, to be honest. That said, I’d check out the WordPress conditional tags to help determine which archive you’re viewing, and amend the arguments passed into the wp_nav_menu() function. For example, conditionally change which menu or menu_container to fetch based on current post type. This would all be at the theme level. CPTUI only registers the post types/taxonomies, it doesn’t handle anything in the theme itself.

    Hope that helps.

    Thread Starter mehargags

    (@mehargags)

    I do understand that it has nothing to do with your plugin, My post is more of an extension thought for your otherwise beautiful plugin.

    Can you give me an idea how to “check” for the Custom Post type and call-in the specific menu ?
    Many thanks

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    This is similar to how I’d end up doing it.

    // Fill in wp_nav_menu() args as necessary.
    $args = array();
    
    // Conditionally set the menu based on the post type being viewed.
    if ( is_post_type_archive( 'something' ) ) {
        $args['menu'] = 'Something';
    } else if ( is_post_type_archive( 'something_else' ) ) {
        $args['menu'] = 'Something Else';
    }
    wp_nav_menu( $args );
    

    You could also use ‘theme_location’ instead of ‘menu’.

    Thread Starter mehargags

    (@mehargags)

    in Which file will the above code go ?

    Sorry I’m not much familiar with wordpress’ file structure. I do know PHP reasonably though my primary profession is being a Sysadmin.

    Would be kind of you to detail me the file/position of insertion of the above code.

    many thanks…

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    It’d need to be placed wherever you’re wanting to output the menu. Typically themes use wp_nav_menu() in header.php, but it could theoretically be anywhere in the theme.

    I’m not going to be able to tell for sure, as I don’t have any access to the site.

    Thread Starter mehargags

    (@mehargags)

    oh I’d love to send you site access FTP/WP-Admin both but how do I do that securely ? there is no PM thing on WP forums I guess ?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Sorry, but that’s not going to be something I can cover support for, beyond replies here on the thread. It’s beyond the scope of what the plugin does.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Assign Separate Menu to each Custom PostType’ is closed to new replies.