Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other wp_list_pages struggles

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #31088
    cjk
    Member

    Hi,

    I have been struggling with this for way too long and I hope someone can help me or point me in the right direction.

    I have a PAGE page that is a parent page and some of the child pages of that parent page have child pages as well, some don’t.

    Lets call the top parent page, “A”
    “A” has child pages “B”, “C”, “D”
    “C” has child pages “E”, “F” and “G”

    on “A” I would like to list pages “B”, “C” and “D”
    on “C” I would like to list pages “E”, “F” and “G”
    on “E”, “F” and “G” I would like to list pages “E”, F”, and “G”

    I tried every example on the codex, and mostly I get a list of every page on my site, not just this post parent and children.

    Anyone have any ideas?

    For example:

    from the codex – The following example will generate a list only if there are child (Pages that designate the current page as a Parent) for the current Page:

    
    $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
    if ($children) { ?>



    But this displays every page on my site. :-(

    #68833
    cjk
    Member

    Getting closer but not quite there yet.

    Here is what I have now in my child functions.php – I use Thematic

    // Add training articles menu list
    function training_articles_menu() {
    global $post;
    if (is_page('training-articles') || ($post->post_parent=="205")) { ?>

    $children = wp_list_pages('depth=1&title_li=&child_of='.$post->ID.'&echo=0');
    if ($children) { ?>



      Training Articles by Chris Krowchuk











    }
    add_action('thematic_belowpost','training_articles_menu');

    This displays the list of the child pages when on the parent and it displays a list of child pages when on a child pages (if there are any).

    The only thing I am missing that I would like is the list of pages that are grandchildren when on a grandchild page, if they exist.

    Does that make sense? It confuses the heck out of me!

    So, I have a Parent page, and under that page I have child pages. Some of these child pages also have children, some do not.

    I can get a list of child pages when on the parent no problem.
    I can get a list of grandchild pages when I am on a child page that has children
    I can’t get a list of grandchild pages when I am on a grandchild page in the same hierarchy. This is what I would like to add somehow?

    Right now I have the grandchild list hard-coded into the grandchild pages and that is fine, but I would like it dynamic obviously.

    Example: http://www.krowchukdressage.com/training-articles/ is the main parent page

    Any wp_list_pages() experts here?

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Other’ is closed to new topics and replies.