Reputation: 6370
I'm using the Advanced custom field plugin and having trouble showing custom fields of children in a loop. I tried this:
<?php <br /> $pages = get_pages(array('child_of' => $post->ID));
foreach($pages as $page)
{
setup_postdata($page);
$fields = get_fields(); print_r($fields);
}
wp_reset_query();
?>
When I put print_r($page)
in it says 1111 so that bit is working (as there's 4 children items).
That code just prints the custom field names of the parent rather than the children, how can I show the children's custom fields?
Upvotes: 1
Views: 599
Reputation: 4828
Have you tried this?
get_pages(array('child_of' => $post->ID, 'parent' => $post->ID, 'hierarchical' => 0))
Upvotes: 0