Support » Fixing WordPress » Exclude posts from parent&children list

  • Hi there,

    after my last post, I am almost there! But I still have one problem…

    I have just added a subpage to a page on my blog for the first time, and would love to display a list in the sidebar on the parent that displays the parent itself, and all children. On the childpages, this same list (parent+children) should be visible.

    I have now used this code:

        $children = '<li><a href="'.get_permalink($post->post_parent).'">'.$parent->post_title.'</a></li>';
        $children .= wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
        $children = '<li><a href="'.get_permalink($post).'">'.$post->post_title.'</a></li>';
        $children .= wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
    echo $children; ?>

    It shows the list of parent and child on a page with children. But what it also does, is show the last post on my homepage sidebar.

    Is there a way to change this code, to exclude posts, and only display parentpages and childpages?

  • The topic ‘Exclude posts from parent&children list’ is closed to new replies.