WordPress.org

Support

Support » Themes and Templates » How to Hide Child Pages in Sidebar

How to Hide Child Pages in Sidebar

  • I’m learning PHP as I go along, so need some guidence. I’m using the theme “Paalam 1.1” which I’ve modified to suit my purposes. One modification defeats me, though. I want the sidebar to display only parent pages, with no child pages shown. The reason? Sidebar is growing too long, and I’ve not yet added all the child pages I intend. So how do I hide the child pages? Searching the forum and codex hasn’t answered my question.

    Here are the possible relevant codes…

    From page.php:

    <div class=”entry”>
    <?php the_content(__(‘Continue Reading »’)); ?>
    <?php wp_link_pages(); ?>
    <?php $sub_pages = wp_list_pages( ‘sort_column=menu_order&depth=1&title_li=&echo=0&child_of=’ . $id );?>
    <?php if ($sub_pages <> “” ){?>
    <p class=”meta”>This page has the following sub pages.</p>

      <?php echo $sub_pages; ?>

    <?php }?>
    </div>

    And from sidebar.php:

      <?php wp_list_pages(‘title_li=’ ); ?>

    Any help is greatly appreciated.

    Terry

Viewing 2 replies - 1 through 2 (of 2 total)
  • Ah hah! I finally found the correct search terms to zero in on a solution to this using google.

    In sidebar.php the original code was:

      <?php wp_list_pages(‘title_li=’ ); ?>

    I changed it to:

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

    Now only the parent pages show in the sidebar, just as I’d wished.

    Terry

    Aint it great when the answers are right there waiting for you? You might also want to read up on the include and exclude functions if you ever decide that you want to display some of those pages.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to Hide Child Pages in Sidebar’ is closed to new replies.
Skip to toolbar