WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] child_of not working in get_pages (6 posts)

  1. klitscher
    Member
    Posted 5 years ago #

    I'm using 2.7 B1 and trying to list the child pages of the page in the post content area. I have a shortcode plugin working, but can't narrow down the pages to just the children:

    $pages = get_pages('child_of=65');
    
        $count = 0;
        foreach($pages as $page)
        {
            ?>
    	<h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
           	<?php
    
    }
    	}

    When I put in a valid Page ID I get no results. When I change it to 0 (all) or leave the child_of parameter out I get all of the pages listed. Any thoughts?

  2. mumebuhi
    Member
    Posted 5 years ago #

    Strangely enough, I could not get this to work on 2.5.1 as well. Thoughts?

  3. karl19
    Member
    Posted 4 years ago #

    The above works fine for me, as long as I take out the last curly bracket, since there is one too many. I'm using WP 2.7.1.

  4. ittekudasai
    Member
    Posted 4 years ago #

    It's not working for me. $post-ID is returning a bad ID, which doesn't have children.

    Perhaps I just need to nuke my DB? I'm in development so that's not the end of the world, but I've about had it trying to make child_of work right now.

  5. karl19
    Member
    Posted 4 years ago #

    Here is another way of getting the children of pages (you can even get the grand children) - query-child-of-page

  6. jwalin
    Member
    Posted 4 years ago #

    try number attribute with chile_of attribute.

Topic Closed

This topic has been closed to new replies.

About this Topic