• This topic has been covered in this Forum, but I am a novice in php code, so you have to be very specific for me.

    I have been able to hide sub-pages by using the following code:

    <?php wp_list_pages(‘exclude=14, 16, 17, 18, 20, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41 &title_li=<h2> </h2>’ ); ?>

    However, I want to be able to list my Main Pages by Menu Order, which means using this code:

    <?php wp_list_pages(‘sort_column=menu_order’); ?>

    But I also want the hidden pages to expand when one visits a sub-page.

    In other words, Only the Main pages are listed whenever a Main Page is Visited. But once a sub-page is visited, the Side Bar lists gets expanded showing the sub-pages.

    In my case, once you visit any of the pages listed in the exception above, – 14,16, 17, etc, all these pages become visible in the Sidebar.

    How do i incorporate all of these

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Well, if ALL the excluded Pages are sub-Pages, then you can simply use the “depth” parameter (depth=1) which will result in not showing any of the subpages, only the Pages on level 1 (=main).
    As for the rest try a search for fold (page) menu or something like that.

    Thread Starter jetlag26

    (@jetlag26)

    I put in the “depth” parameter instead of “exclude” which is:

    <?php wp_list_pages(‘depth=1) &title_li=<h2> </h2>’ ); ?>

    This worked nicely. Thanks

    I did a search for Fold and found this at http://wordpress.org/support/topic/26505

    * About us
    * Products
    — * Apples
    — * Bananas
    — * Oranges
    * Contact us

    <?php if(is_page(‘Products’) || is_page(‘Apples’) || is_page(‘Bananas’) || is_page(‘Oranges’)) : ?>
    <?php wp_list_pages(); ?>
    <?php else : ?>
    <?php wp_list_pages(‘exclude=1, 2, 3’); ?>
    <?php endif; ?>

    ‘1, 2, 3’ in the exclude parameter would equal the numeric Page IDs for Apples, Bananas and Oranges.

    If by “sub pages can fold in and out” you mean you’re looking to hide the Page link when on that particular Page:

    <?php if(is_page(‘Products’)) : ?>
    <?php wp_list_pages(); ?>
    <?php elseif(is_page(‘Apples’)) : ?>
    <?php wp_list_pages(‘exclude=1’); ?>
    <?php elseif(is_page(‘Bananas’)) : ?>
    <?php wp_list_pages(‘exclude=2’); ?>
    <?php elseif(is_page(‘Oranges’)) : ?>
    <?php wp_list_pages(‘exclude=3’); ?>
    <?php else : ?>
    <?php wp_list_pages(‘exclude=1, 2, 3’); ?>
    <?php endif; ?>

    I think I will play around with this to see if I get the results I want,

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Page Order and Expansion’ is closed to new replies.