I am trying to show related services through my single-services.php template. I have used the ACF relationship field. When I print_r the field data, it all works. However, when I try to call specific fields into my layout with meta_query, it doesn't work and I can't see why.
$related_services = get_posts(array(
'post_type' => 'services', // name of custom post type
'meta_query' => array(
array(
'key' => 'related_services', // name of custom field
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE'
)
)
));
if( $related_services ):
foreach( $related_services as $related_service ):
$icon = get_field('service_icon', $related_service->ID);
echo $icon;
endforeach;
endif;