WordPress.org

Support

Support » Themes and Templates » Complex Submenu

Complex Submenu

  • I need to list a sidebar submenu for certain pages. It is a complex if, elseif, else statement that uses wp_list_pages() function and other functionality.

    For top level pages: Home, About, Contact, I don’t want a submenu to appear, it would just be a sidebar with other functionality, this would be if is_page('about'); then it would show a different type of menu.

    The problem, I am running into is with the submenu for subpages

    About, Programs, Media, etc are all “sectional” pages, meaning they are the main top-level pages where the rest of the content is stored. It has it’s own menu, whereby all of the pages have a top “overview” page which is domain.com/about/ then, when you go deeper, the should change with the indented list, shows the child pages, if they exist, so domain.com/about/features/ should show

    – Overview
    Features *current-page*
    – – Sub Page One (Child of Features page)
    – – Sub Page Two
    – – Sub Page Three
    – Functions
    – Options
    – Foobar

    The next third-level should now get rid of the grandparent pages and now only show a link to the parent page so

    domain.com/about/page-one/sub-page/

    – Up One Level
    Sub Page One *current-page*
    – Sub Page Two
    – Sub Page Three

    So on and so forth for any future /sub-sub-sub-sub-pages/

    Do you think this is doable?

Viewing 11 replies - 1 through 11 (of 11 total)
  • *bump*

    *bump*

    No one can think of how I can using wp_list_pages() and $wp->posts to create a dynamic show sub pages but, show this and subpages menu?

    Hi GuruXL,
    I have been thinking about this a little and it does seem doable, setting everything up would take a little work though. I would suggest something along these lines:

    <?php if (is_page('PageName 1')) { echo 'wp_list_pages('exclude=1,5');' } elseif (is_page('PageName 2')) { echo 'wp_list_pages('exclude=3,7');' } ?>

    This may point you in the right direction, but will most likely need some work, you should find the wp_list_pages
    useful for reference also.

    Hope this helps,
    Chet

    ewoodside,

    Currently, I am using this code:

    <?php
      if ( $post->post_parent )
    
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
    else
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
    if ($children) { ?>
    <ul>
    <?php echo $children; ?>
    </ul>
    <?php } ?>

    What I need to do is add a conditional that if you are on the parent page or grandchild page, you for the parents page show the “Overview” in a “li” tag with link to parent page, in the grandchild page, you show a “li” tag with “Up One Level”, like a recursive directory script.

    Top Level Page
    =============
    – Overview (current page) [bold]
    – Page One
    – Page Two

    Sub Page (Level 1)
    =============
    – Overview
    – Page One (current page) [bold]
    – – Sub-Page One
    – – Sub-Page Two
    – – Sub-Page Three
    – Page Two

    Sub Sub Page (Level 2)
    ================

    – Up One Level
    – Sub Page One
    – Sub Page Two (current page) [bold]
    – Sub Page Three

    You see how it works now?

    I’m playing with a slightly different but related approach to dynamic page menus here.
    (click ‘Affiliate Solutions’, then ‘Affiliate Program Expertise’ –
    the down side of my approach is I don’t use wp_list_pages() but mysql in stead so probably not a wise route if you are trying to create a perfectly future proof and distribution ready theme.

    Lemme know if you want the code – if there is more interest in dynamic nested page navigation I’ll try to put it in plugin form with configuration interface in the admin panel or some such.

    AndreSC, if you would, please that would be helpful.

    Thanks AndreSC, i’ll see if I can re-write the code for my purposes, until I can come up with a more future-proof version.

    Hello AndreSC!

    I was looking for such solution for a long time, and finally found here =)

    Unfortunately, I’m just a beginner in php/theme coding, can you please help me with:
    1)where to put that code?
    2)is it enough to just put it, or it requires additional finetunung, I mean changing some specific data, or something

    Maybe there is already done plugin that you mentioned?
    Thank you anyway!

    Kamneed

    I don’t know if any changes have been made as of yet.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Complex Submenu’ is closed to new replies.