• Resolved tstrebeck

    (@tstrebeck)


    Here’s the basic structure of my site:

    Section 1
    – subpage
    – – sub subpage
    – – sub subpage
    – subpage
    – – sub subpage
    – subpage

    Section 2
    – subpage
    – – sub subpage
    – – sub subpage
    – subpage
    – subpage
    – – sub subpage
    – – sub subpage

    Section 3
    – subpage
    – – sub subpage
    – – sub subpage
    – subpage
    – subpage

    What I’m wanting to do is display is the first level of children of each section at the top level of that specific directory and for all the children underneath it. Is there some way to accomplish this? Will I need to create 3 different menus and then set up some sort of if/then scenario?

    Thanks for your help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    I think that’s a reasonable approach. You can specify which menu to display as a parameter when you call wp_nav_menu(array('menu'=>'section-1')) from the header template. The follow up question is how does your if/then logic know which section is being requested? This depends on how your site is structured. Some data you could use includes the various is_*() template tags, the global $wp_query->query_vars, and $_SERVER['REQUEST_URI'].

    Thread Starter tstrebeck

    (@tstrebeck)

    What do you mean by how it’s structured?

    Moderator bcworkz

    (@bcworkz)

    By how your pages are logically organized internally. The point being how can your code know what the parent section is for any particular sub page or sub sub page? For example, if all pages are hierarchical, you could simply walk up the parent path. Or if all pages of a particular section have a taxonomy term in common, you could do a tax query for top level pages to get the section. Or if your permalinks always contain the section reference, you can extract it from the request URI.

    Your code needs to basically say “If some condition is X then output the A menu.” Exactly what that X condition is depends on the “structure” of your site.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display menu for pages under specific directory’ is closed to new replies.