Support » Fixing WordPress » Dynamic menu depending on depth of sub-pages

  • As i posted on earlier tread ( ) I have a site build using pages, and sub-pages. It’s structure is 2 levels deep, i.e. parent pages -> child sup-pages.

    I want dynamic menu on the sidebar, depending if parent or child. Also, depending if current page has childs or not.
    To put it more precise:
    on Home i want list of parent pages (top level pages)
    on each of top level pages i want list of it’s sub-pages, unless it doesn’t have any, then i want it’s siblings
    on child pages (second level) i want list of it’s childs siblings (other second level pages, childs of same parent page)

    so far i have this code, which i found somewhere (sorry, really don’t remember were was it):

      if (basename($_SERVER["REQUEST_URI"]) == "") {art_menu_items(false);}
      else if($post->post_parent)
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
      if ($children) { ?>
      <?php echo $children; ?>
      <?php } ?>

    This lists:
    for Home – other top level pages
    for all other pages it shows theirs childs if they have them. If not it’s shows nothing, where i want the siblings to be shown
    On second level (sub-pages) it shows teir siblings (so exactly what i want).
    So how to change that code so that if one of top level pages don’t have childs menu will list the list of all top level pages.

    Thanks in advance,

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Dynamic menu depending on depth of sub-pages’ is closed to new replies.