Title: Complex Submenu
Last modified: August 18, 2016

---

# Complex Submenu

 *  [guruxl](https://wordpress.org/support/users/guruxl/)
 * (@guruxl)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/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)

 *  Thread Starter [guruxl](https://wordpress.org/support/users/guruxl/)
 * (@guruxl)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/complex-submenu/#post-660095)
 * *bump*
 *  Thread Starter [guruxl](https://wordpress.org/support/users/guruxl/)
 * (@guruxl)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/complex-submenu/#post-660129)
 * *bump*
 *  Thread Starter [guruxl](https://wordpress.org/support/users/guruxl/)
 * (@guruxl)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/complex-submenu/#post-660149)
 * 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?
 *  [cwoodside](https://wordpress.org/support/users/cwoodside/)
 * (@cwoodside)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/complex-submenu/#post-660150)
 * 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](http://codex.wordpress.org/wp_list_pages)
   
   useful for reference also.
 * Hope this helps,
    Chet
 *  Thread Starter [guruxl](https://wordpress.org/support/users/guruxl/)
 * (@guruxl)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/complex-submenu/#post-660156)
 * 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?
 *  [AndreSC](https://wordpress.org/support/users/andresc/)
 * (@andresc)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/complex-submenu/#post-660157)
 * I’m playing with a slightly different but related approach to dynamic page menus
   [here](http://forgebusiness.com/affiliate_marketing/).
    (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.
 *  Thread Starter [guruxl](https://wordpress.org/support/users/guruxl/)
 * (@guruxl)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/complex-submenu/#post-660159)
 * AndreSC, if you would, please that would be helpful.
 *  [AndreSC](https://wordpress.org/support/users/andresc/)
 * (@andresc)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/complex-submenu/#post-660161)
 * sure, [rough code for dynamic nested page menus here](http://pixelplexus.co.za/blog/2007/12/06/first-stab-at-dynamic-page-navigation-for-wordpress/).
 * Hope it helps 🙂
 *  Thread Starter [guruxl](https://wordpress.org/support/users/guruxl/)
 * (@guruxl)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/complex-submenu/#post-660167)
 * 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.
 *  [kamneed](https://wordpress.org/support/users/kamneed/)
 * (@kamneed)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/complex-submenu/#post-660192)
 * 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
 *  Thread Starter [guruxl](https://wordpress.org/support/users/guruxl/)
 * (@guruxl)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/complex-submenu/#post-660206)
 * 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.

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [navigation](https://wordpress.org/support/topic-tag/navigation/)
 * [page](https://wordpress.org/support/topic-tag/page/)
 * [submenu](https://wordpress.org/support/topic-tag/submenu/)

 * 11 replies
 * 4 participants
 * Last reply from: [guruxl](https://wordpress.org/support/users/guruxl/)
 * Last activity: [18 years, 2 months ago](https://wordpress.org/support/topic/complex-submenu/#post-660206)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
