I’ve used the wordpress plugin – advanced custom field and would like to show an array of a child, here’s my code:
I’m using this code to show the custom fields data from a specific page ID’s children:
<?php $args = array(
'depth' => 0,
'child_of' => 411 );
$pages = get_pages(array('child_of'));
foreach($pages as $post)
{
setup_postdata($post);
$fields = get_fields();
if($fields->company_name != "") : ?>
<h2><?php echo $fields->company_name; ?></h2>
<?php else : ?>
<?php endif; ?>
<?php
}
wp_reset_query();
?>
This is the code I’m using to show the checkbox data of the page itself (i.e it’s not a parent/child):
<?php $catNames = array( 'branding','creative','development','exhibition','packaging','print','seo','social_media','usability','web','advertising','campaign','content','feasibility','publishing','research','strategy');
foreach($catNames as $name){
if(in_array($name, get_field('categories') )){
echo '<a href="/tags/design/'.$name.'" title="'.$name.'">'.ucwords($name).'</a>';
}
}
?>
I want to combine the two together so underneath the H2 tag in the first code box I want to show the checkbox data of the child, how can this be done?
UPDATE:
When I add the checkbox code to the child code, I can’t get the data to display, it’s either blank or has an error.
This is the page I’m working on. The first thumbnail has been hardcoded, the second and third thumbnails should pick up the tags with the code above but it doesn’t.
This will return the ticked checkboxes: