WordPress.org

Ready to get started?Download WordPress

Forums

wp_list_pages hiding sub-pages UNLESS viewing one of those subpages? (1 post)

  1. CrazySerb
    Member
    Posted 6 years ago #

    Ok, I know this is obviously not a feature of wp_list_pages() function, but I've been trying out a whole lot of plugins and suggestions on how to actually hide sub-pages from being listed by that function UNLESS the user is actually on one of those subpages and viewing it.

    So, if anyone can help out here and has done this before, I'd love to hear how...

    And, just for clarification, I want the menu I'm building to look like this:

    - Parent Page 1
    - Parent Page 2
    - Parent Page 3
    ...

    And that will be default menu for all pages until a user visits one of those parent pages AND they have some sub-pages under them (if they don't, well, then nothing changes), in which case the menu will change into this (assuming they clicked on Parent Page 2 and that page had 2 more pages listed under it as sub-pages):

    - Parent Page 1
    - Parent Page 2
    -- Sub Page 1
    -- Sub Page 2
    - Parent Page 3
    ...

    I am looking to do this only on that 1 level (parent and child page), nothing deeper and more complicated than that.

    And it doesn't have to be done through wp_list_pages(), as I can use any custom SQL queries or functions here (I really don't care, as long as it gets the job done).

    Anyone have any ideas?

Topic Closed

This topic has been closed to new replies.

About this Topic