Forums

create conditional menus (2 posts)

  1. manturafs
    Member
    Posted 2 years ago #

    I’m having a problem creating a conditional sidebar menu. i've tried a number of widgets, but none of them what i want, even if i edit the plugin.

    basically, i have a horizontal menu that represents the parent pages. now what i want is a conditional sidebar that shows only children of the current parent page.

    that's not too difficult, but my problem is that i have multiple levels of children and i only want children and grandchildren visible. further complicating things, i also want the grandchildren hidden if the user is on the main parent page or another children page.

    as an example, let's say my horizontal menu is:
    H1 - H2 - H3 - H4

    when on H2, i have the following tree:

    H2
    h1
    -h1a
    -h1b
    h2
    -h2a
    -h2b
    --h2b1
    h3
    h4

    where H2 is the parent, h1-h4 are the children, and h#letter are the grandchildren and h2b1 is a great grandchild. this is what i want to see if i'm on h1 or h1a

    h1
    -h1a
    -h1b
    h2
    h3
    h4

    similarly, this is what i want to see if i'm on the h2 or h2b page:

    h1
    h2
    -h2a
    -h2b
    h3
    h4

    can this be done? i haven't been able to figure it out since i'm not a skilled coder. all i want is a list of children with grandchildren visible if on the respective child page or any of the sibling grandchildren. please help!

  2. manturafs
    Member
    Posted 2 years ago #

    can it be done with wp_list_pages alone. i know i can list children with wp_list_pages, but just haven't figured out how to limit the depth of children and make visibility conditional. perhaps the latter can be done through css?

Topic Closed

This topic has been closed to new replies.

About this Topic