WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to list child pages?? (11 posts)

  1. Raider000
    Member
    Posted 11 months ago #

    Hi,

    I am trying to list the child pages of my current page on my sidebar.

    I tried it like this
    wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
    but it won't work. It shows nothing. var_dump says: string(0) ""

  2. keesiemeijer
    moderator
    Posted 11 months ago #

    The post id is probably not available in the sidebar. Try this:

    global $post;
    $pages = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
  3. Raider000
    Member
    Posted 11 months ago #

    Thanks but this won't work. It still says NULL.

  4. viky081
    Member
    Posted 11 months ago #

    <?php
    global $post;
      $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
      if ($children) { ?>
      <ul>
      <?php echo $children; ?>
      </ul>
      <?php } ?>

    Try this hope it may work.

  5. Raider000
    Member
    Posted 11 months ago #

    Thanks but nothing changed. Still the same.

  6. esmi
    Forum Moderator
    Posted 11 months ago #

    What theme are you using? Where did you download it from?

  7. Raider000
    Member
    Posted 11 months ago #

    I use my own theme.

  8. esmi
    Forum Moderator
    Posted 11 months ago #

    How many loops/queries are running on the page?

  9. Raider000
    Member
    Posted 11 months ago #

    There are 2. Normal posts and CPT.

  10. esmi
    Forum Moderator
    Posted 11 months ago #

    Are you resetting the query after each loop?

  11. Raider000
    Member
    Posted 11 months ago #

    Yes, everytime. But nevermind, I use the plugin Gecka Submenu to this now. Thanks anyway!

Reply

You must log in to post.

About this Topic