WordPress.org

Ready to get started?Download WordPress

Forums

Dynamic menu depending on depth of sub-pages (3 posts)

  1. Krzyhacz
    Member
    Posted 5 years ago #

    As i posted on earlier tread ( http://wordpress.org/support/topic/224695?replies=1#post-922321 ) 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):

    <?php
      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");
      else
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
      if ($children) { ?>
      <ul>
      <?php echo $children; ?>
      </ul>
      <?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,
    Chris

  2. chuckienorton
    Member
    Posted 5 years ago #

    Chris, I'm looking for same thing. Did you ever find a solution?

    Thanks!
    Chuck

  3. chuckienorton
    Member
    Posted 5 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags