WordPress.org

Ready to get started?Download WordPress

Forums

listing child pages (4 posts)

  1. vickyh
    Member
    Posted 6 years ago #

    I'm using a static home page and have another page for displaying the list of blog posts. I also have some static pages as subpages of the main blog page.

    I've used the code

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

    in the sidebar file to display a list of sub pages. It's working fine on every single page in the site, except on the blog page. Nothing shows up at all. So i can't then get to the sub pages of the blog.

    What have I done wrong?

  2. sunburntkamel
    Member
    Posted 6 years ago #

    unfortunately wordpress doesn't know what page the blog page is (basically, it's the home page, not a page)

    it's best to just set the child_of to match your blog page's ID. you can use is_home() to run different subpage code on the blog page.

    i use some really complex code to do it on my own site. it's a pain.

  3. depperson
    Member
    Posted 5 years ago #

    Just bumping this post for a similar question:

    I use the them Amazing Grace theme found in the WP themes directory.
    I have my pages listed at the top, but I would like the Tabs (just below the site name) to show as the the child pages respectively.

    Any place to start?

    BTW: I am a rank amateur when it comes to coding, but if you can give me the path to take, I can cut my way through it!

  4. depperson
    Member
    Posted 5 years ago #

    The coding that vickyh used works wonderfully in my site - with one exception: HOW CAN I LIMIT IT TO ONE-SUBLEVEL?

    When I click on a sub-page, if they also have sub-pages, then THEY show up in the tabble menu.

    I have tried the depth=1 or depth=2 to no avail. Any help?

Topic Closed

This topic has been closed to new replies.

About this Topic