WordPress.org

Support

Support » How-To and Troubleshooting » Page & Sub-Page Exclusion From ‘wp_list_pages’

Page & Sub-Page Exclusion From ‘wp_list_pages’

  • Hi guys. I’m developing a wordpress blog for use as a CMS for a client and I’m having a little trouble with navigation.

    Right now, I have a manually coded navigation but I would like to utilise the wp_list_pages function in order to provide an easier to manage navigation.

    Looking at past topics on this board, there have been a few posts asking how to exclude pages from wp_list_pages based on page title. For example,

    <?php
    $page1 = get_page_by_title ('Client Area');
    $page2 = get_page_by_title ('Services');
    $page3 = get_page_by_title ('Galleries');
    
    wp_list_pages('sort_column=menu_order&exclude=' . $page1->ID . ',' . $page2->ID . ',' . $page3->ID . '&title_li=');
    ?>

    However, I was wondering if there was any way to write this in a similar way so that when it excludes a parent page, it also excludes all child pages of that page?

    For example, If a page called “Services” had two sub-pages called “Weddings” and “Events”, when I excluded “Services” it automatically excludes all child pages.

    Thanks for your time,
    OB.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Page & Sub-Page Exclusion From ‘wp_list_pages’’ is closed to new replies.
Skip to toolbar