ThemeShaper Forums » Thematic

[closed]

How to list children pages in sidebar?

(3 posts)
  • Started 4 years ago by kpolice
  • Latest reply from jonnycj
  • This topic is not resolved
  1. kpolice
    Member

    Hi,

    I have the following page structure:
    Page 1
    Page 2
    ---Page 2.1
    ---Page 2.2
    Page 3

    And what I want to achieve is put a menu in the sidebar to list the subpages of the current page, so if I am on page 2 I should list pages 2.1 and 2.2 but I cant get my code to work.

    In other themes I have used I can just use:
    wp_list_pages( 'title_li=&child_of=' . $post->ID);

    but with thematic $post is always empty so it is generating pretty much a sitemap instead of a menu. My code is this:

    function wa_primary_aside()
    {

    echo thematic_before_widget_area('primary-aside');
    wp_list_pages( 'title_li=&child_of=' . $post->ID );
    echo thematic_after_widget_area('primary-aside');
    }

    add_action('widget_area_primary_aside', 'wa_primary_aside', 10);

    Any help is appreciated.

    Thanks

    Posted 4 years ago #
  2. don't know if you resolved this, but i am using Menus Plus+ in conjunction with Widget Context. I create the menu in Menus Plus+, then put its corresponding widget into the sidebar... and control what pages it shows on w/ Widget Context.

    Posted 4 years ago #
  3. jonnycj
    Member

    If not this works to display child pages as a list in a widget area.
    The code can be pasted into an aside inside a PHP Code widget

    <?php
    // this actually works in thematic for listing child pages
    // the key is defining global $post
    //after that most of the wp_list_pages from the codex work
    global $post;
    ?>
    <?php
      $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
      if ($children) { ?>
      <ul>
      <?php echo $children; ?>
      </ul>
      <?php } ?>
    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.