WordPress.org

Ready to get started?Download WordPress

Forums

Displaying one set of subpages on all subpages (3 posts)

  1. animald
    Member
    Posted 2 years ago #

    Hi,

    I'm having trouble pulling in a pages subpages and having them be displayed on the subpages themselves.

    I have manually listed the parent page items and want to target a particular pages subpages to be displayed below the corresponding parent page.

    I am using the following code, it works to a point, but it also pulls in the other subpages:

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

    The parent page ID is '7'.

    Thanks in advance!

  2. animald
    Member
    Posted 2 years ago #

    This is how it looks in the list (the parent page is 'About Us'):

    <li><a href="<?php echo get_permalink(7); ?>">About Us</a></li>
            <?php if($post->post_parent){
                $children = wp_list_pages("title_li=&child_of=7&echo=0");
            }else{
                $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
            }
            if ($children) { ?>
                <ul>
                    <?php echo $children; ?>
                </ul>
            <?php } ?>
            <li><a href="<?php echo get_permalink(9); ?>">News</a></li>
            <li><a href="<?php echo get_permalink(11); ?>">Gallery</a></li>
  3. animald
    Member
    Posted 2 years ago #

    BUMP. I really need help with this

Topic Closed

This topic has been closed to new replies.

About this Topic