开发者

Wordpress - Show custom fields of children on parent page

开发者 https://www.devze.com 2023-02-22 07:17 出处:网络
I\'m using the Advanced custom field plugin and having trouble showing custom fields of children in a loop. I tried this:

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);
$f开发者_运维技巧ields = 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?


It should've been post instead of page, doh!

http://support.plugins.elliotcondon.com/discussion/43/show-page-children-or-subpages-with-custom-fields


Have you tried this?

get_pages(array('child_of' => $post->ID, 'parent' => $post->ID, 'hierarchical' => 0))
0

精彩评论

暂无评论...
验证码 换一张
取 消