Selectively list display of pages

The following code displays page names in a header.

Can this command be modified to NOT display a specific page?

<?php wp_list_pages('title_li='); ?>

Also, how do I determine a Page ID?

  • Hiranthi
    • Recruit

    As stated on this page, this function displays pages as links (site navigation). Perhaps you mean the same, but to me it sounds like you are using it in the html header (as in: title-tag of the page).

    That page (one I linked to - site btw) also displays all the ways you can use the wp_list_pages() function (like excluding pages and sorts).

    If you would like to add a custom field to a page in order to filter which pages you would like to add in the navigation, you could use the following:

    $PageOptions = array(
    'title_li' => '',
    'meta_key' => 'NAME_CUSTOM_FIELD',
    'meta_value' => 'VALUE_CUSTOM_FIELD',
    'depth' => '1'

    More info on that code can be found here: Contents Magic

  • BobSgt
    • Design Lord, Child of Thor

    So I am trying to add code to the header (Oceanmist Theme) to only list the child pages of the page being displayed. I added the code snippit from:

    The page is displayed without the subpages listed in the header, can someone explain wy it is not being displayed?

    <div id="top-nav">
    <ul id="pagetabs">

    • <?php
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
      if ($children) { ?>

        <?php echo $children; ?>

      <?php } ?>


  • Hiranthi
    • Recruit

    Then I'm not sure what's going wrong. I'm using it in my normal WP install and it's working like a charm.. Just to be sure, I'll post the code here:

    <?php if($post->post_parent) {
    $parent_title = get_the_title($post->post_parent);
    $current = '<li class="header">' . $parent_title . '';
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&depth=1&sort_column=menu_order&echo=0");
    } else {
    $current = '<li class="header">' . get_the_title($post->ID) . '';
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&depth=1&sort_column=menu_order&echo=0");
    <div id="sidecolumn">

      <?php if ($children) { ?>

      • <?php echo $current; ?>
        <?php echo $children; ?>
    • <?php } ?>


  • BobSgt
    • Design Lord, Child of Thor

    I inserted the code you just sent and it worked.

    THAnK YOU! It is now working as I hoped.

    I edited out the line following the else statement => $current = '<li class="header">' . get_the_title($post->ID) . '';

    and it presented as I had hoped. I have coded in assembler, Fortran etc. but not php (obviously I need to get a good php book). so I can figure it out trial and error without knowing php syntax.

    The other logic has not been tested, but I will get there eventually. is there a way to comment out a line of php rather than deleteing?

  • Hiranthi
    • Recruit

    I'm glad it works :slight_smile:

    There most definetely is a way to comment out code in PHP. If you want to 'commentize' just one line, use double slashes (//) in front of that line. If you want to 'commentize' multiple lines, juse /* in front of the first line and */ after the last line. Hope that makes sense :wink:

  • BobSgt
    • Design Lord, Child of Thor

    At my day job, so this is on hold for now. I appreciate your assistance.

    What I want to do is have drill down geographical hierarchies,

    Continent (Root Page) => Country (Child page) => State (Child of Country Page) . At the state level offer a blog registration that can be set up at the community level ie North America => United States => New Jersey Blog title "Absecon-Island-NJ" or "Ocean-City-NJ". I then want a blog roll associated with the state to show what blogs are available for example in NJ. Can a blog have sub blogs? ie NJ Blog, Ocean-City-NJ child blog?

    What would you recommend as the best way to do this. Just because I have pages set up right now, I can change?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.