WordPress.org

Ready to get started?Download WordPress

Forums

Displaying child pages of parent pages problem (10 posts)

  1. peiqinglong
    Member
    Posted 8 years ago #

    So I read the part on displaying child pages that are associated with parent pages here: http://codex.wordpress.org/Template_Tags/wp_list_pages

    and here is the code I'm using in my sidebar, but nothing shows up. Am I doing something wrong?

    <?php if (is_page('mac'))
    {
    echo "<div class='sidebar'>";
    echo "<h2>Mac Articles</h2>

      ";
      print wp_list_pages("title_li=&child_of=".$post->ID."&sort_column=menu_order&show_date=modified&date_format=$date_format");
      echo "

    </div><!-- sidebar -->";
    } ?>

    All I want to be able to do is display the child pages of 1 specific parent page in the sidebar. Thanks for any and all help!

  2. moshu
    Member
    Posted 8 years ago #

    Then you don't need that complicated thing :0
    Just to make sure I understood correctly your request. You always want to display the same list of children/subpages of a certain X parent page?
    If yes, just read carefully the parameters:
    http://codex.wordpress.org/Template_Tags/wp_list_pages

  3. peiqinglong
    Member
    Posted 8 years ago #

    For example, I have a page I titled Mac. I want to use that parent page to house a bunch of child pages that will be tips and tricks. I would like to have any current and new child pages created under the Mac parent page to appear in the sidebar. I do want to be able to do this with a few other pages, but not ALL the parent pages.

  4. moshu
    Member
    Posted 8 years ago #

    So, the child_of=342 doesn't work? (provided page_id=342 is your Mac Page)

  5. peiqinglong
    Member
    Posted 8 years ago #

    Hrmmm, if I put wp_list_pages("title_li=&child_of=63".$post->ID."&sort_column=menu_order&show_date=modified&date_format=$date_format");

    It just displays my forum and profile which aren't even in the pages list.

  6. peiqinglong
    Member
    Posted 8 years ago #

    I just tried doing this:

    print wp_list_pages("child_of='63'&echo=0"); and that still did the same thing.

    If I just do a:

    print wp_list_pages("mac"); all my pages display.

  7. moshu
    Member
    Posted 8 years ago #

    <?php wp_list_pages('child_of=63'); ?>
    That's all. And notice the single quotes.

  8. peiqinglong
    Member
    Posted 8 years ago #

    Hrmmm...that worked. Although it still does display the Forums and Profile which aren't pages as far as I can tell from the admin panel.

    http://www.bui4ever.com/mac, all the way in the sidebar to the bottom.

  9. moody
    Member
    Posted 8 years ago #

    Have you looked at the Fold page list plugin?

    You also might want to play with the exclude string of these functions.

  10. peiqinglong
    Member
    Posted 8 years ago #

    moody, that didn't work.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags