• Resolved Anup Dhal

    (@anupsanu)


    Hello WordPress Team,

    I have some problem to create dynamic menus depending on the post. so what exactly I want is, I want to create separate menus for separate posts. Below I have given an example how it should look like.

    i.e: 

    JAVA -> Sub Java1, Sub Java2, Sub Java3 etc.

    PHP -> Sub PHP1, Sub PHP2, Sub PHP2 etc.

    HTML -> Sub HTML1, Sub HTML2, Sub HTML3 etc. 

    Here (JAVA, PHP, HTML) are posts. on click of this post, it will take to Java post page and menu also will get change also on click of other posts(PHP/HTML) menu should change related to posts and so on.

    Also under sub menu, I want to create related sub-sub menu in the left or right side of the page.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    When wp_nav_menu() is called on a template, you can specify which menu to display regardless of the assigned menu for the location. You can find out what post ID is being requested on the header template with get_queried_object_id(). Build some sort of data array relating post IDs to menus. With the post ID, load the appropriate menu by passing the desired menu as the “menu” argument to the wp_nav_menu() call, usually in your theme’s header.php template. If your menu is loaded in a sidebar, the same logic applies, except do so on the proper sidebar template.

    In a similar manner you can decide to load a left or right sidebar template based on the requested ID. Exactly how you specify what sidebar to load depends on your theme.

Viewing 1 replies (of 1 total)

The topic ‘How to create Different Menus Depending upon the Post?’ is closed to new replies.