Forums

Displaying child pages in sidebar (2 posts)

  1. chackowsky
    Member
    Posted 1 year ago #

    I would like to display in a PHP sidebar (using the PHP Code widget) the children of the currently displayed code. I’ve tried examples from the codex
    http://codex.wordpress.org/Template_Tags/wp_list_pages
    but what they consistently do is display children of the home page rather than those of the current page.

    For instance

    <?php
      if($post->post_parent)
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&depth=1");
      else
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1");
      if ($children) { ?>
      <ul>
      <?php echo $children; ?>
      </ul>
      <?php } ?>

    (My only change was to add depth=1 since I don't want the entire "web-map", just the proper children of this page.)

    Any thoughts?

  2. chackowsky
    Member
    Posted 1 year ago #

    Whoops. All good. Found a plug-in to do the job: http://www.dagondesign.com/articles/list-subpages-plugin-for-wordpress/

Topic Closed

This topic has been closed to new replies.

About this Topic