[wp-testers] get_pages() not returning ancestors
Austin Matzko
if.website at gmail.com
Mon Nov 23 15:25:28 UTC 2009
On Mon, Nov 23, 2009 at 9:20 AM, Nathan Rice <ncrice at gmail.com> wrote:
> Would anyone have an idea as to why get_pages() wouldn't return ancestors?
>
> $pages = get_pages();
> foreach((array)$pages as $page) {
> print_r($page);
> }
>
> I'm using something similar to this code in a function in functions.php,
> which is called in a Widget Form I'm building. For some reason
> $page->ancestors isn't returned for pages that I *know* have parents. It's
> not like it's empty or anything ... the object key doesn't even exist,
> although all the others return just fine (title, excerpt, etc.)
Do you mean "post_parent"? Because get_pages() doesn't call
_get_post_ancestors(), unlike get_post(), so the "ancestors" property
of the page object won't be set.
However, you should see "post_parent" set if that page has a parent object.
More information about the wp-testers
mailing list