Forums

[resolved] changes to get_children() 2.9 (3 posts)

  1. starman2049
    Member
    Posted 2 years ago #

    $childPages = get_children('post_parent='.$post->ID);

    if ( $post->post_parent && !is_array($childPages))
    {
    }

    Prior to 2.9.2 in the above code get_children() appears to return an object that returns false from is_array($childPages) when there are no child pages, now in 2.9.2 it returns true.

    Is that right, or am I missing something in my code.

    Any help is appreciated!

  2. jonradio
    Member
    Posted 2 years ago #

    From the last release of 2.8 to the first release of 2.9, I ran into problems with get_children, too. For me, the answer was this:

    As of Version 2.6, you must pass a non-empty post_type parameter (either attachment or page).

    ref. - http://codex.wordpress.org/Function_Reference/get_children

    You haven't specified post_type. Curiously, its absence did not cause me any problems until 2.9 came along, despite the reference to 2.6 in the documentation.

    For more info, see http://wordpress.org/support/topic/343919

  3. starman2049
    Member
    Posted 2 years ago #

    ok so I looked at post.php and it looks like before 2.9 get_children() would return boolean false if there were no children and now it returns an empty array

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.