Hi,
I have created a custom post type “Stories” where I’ve also created a custom taxonomy named “Segment”. Connected to this custom taxonomy I’ve created a custom field “segment_image” (set to array) ruled to be shown if Taxonomy is equal to “Segment”. The idea is that each term will have an image assigned and will be displayed in the post depending on the segment chosen.
In the back-end everything seems to be connected correctly and the field is showing in the Taxonomy page to upload an image. The problem I’m having is that I can’t find the way to retrieve that image ID or URL in my template page.
Here is my code:
<?php
$args = array(
'post_type' => 'stories',
'post_status' => 'publish',
'posts_per_page' => -1
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
$segment = get_field('segment_story');
$segment_bg = get_field('segment_image', $segment);
echo 'bg: ' . $segment_bg['url'];
I’ve even created a Taxonomy field type in my custom post type “Stories” called “segment_story” to force getting the term array manually but still nothing.
I would appreciate any help with this! I’ve checked several ACF documentation pages and also checked some threads here but nothing worked for me so far.
Thanks in advance!
I.