Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress Menu Help

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #29318
    cmaclean
    Member

    I have a WordPress site and I’m having trouble figuring out how to display my vertical sidebar menu the way I need it:

    Here’s a sample of the menu:

    HOME
    BLOG
    BASICS
    – Sub Menu 1
    – Sub Menu 2
    – Sub Menu 3
    EDUCATION
    WORKSHOPS
    – Sub Menu 1
    – Sub Menu 2
    – Sub Menu 3
    ORDER NOW

    When a page without children is active it should display as:

    HOME
    BLOG
    BASICS
    EDUCATION
    WORKSHOPS
    ORDER NOW

    I’ve got that setup without any troubles.

    When a page with a child is active (in this case ‘BASICS’), I want the menu to show as:

    HOME
    BLOG
    BASICS
    – Sub Menu 1
    – Sub Menu 2
    – Sub Menu 3
    EDUCATION
    WORKSHOPS
    ORDER NOW

    …where only the active page’s children are displayed. With my current setup, only the children show on the parent page (no other menu items are displayed).

    I could write a workaround manually, but am looking for a dynamic snippet. Here’s what I currently have:

    Code:
      ID;
      if ($post->post_parent) {
      $page = $post->post_parent;
      }
      $children=wp_list_pages(‘echo=0&child_of=’ . $page . ‘&title_li=’);
      if ($children) {
      $output = wp_list_pages(‘echo=0&child_of=’ . $page . ‘&title_li=’);
      }
      }
      echo $output;
      ?>

    Thanks!

Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.