I am trying to pull an image from a custom taxonomy called “communities.” The field is called “community_logo” which pulls the image URL. If the taxonomy is “riverwalk” I need the image to pull on all the pages that are in the “riverwalk” taxonomy. I am failing.
I am attempting to use your example:
$terms = get_the_terms($post->ID, 'apartment'); // This is the custom post type
if( !empty($terms) )
$term = array_pop($terms);
$custom_field = get_field('community_logo', $term );
$community = $custom_field;
Then I’m pulling it like so:
<div id="apartLogo"><img src="<?php the_field('community_logo', 'location_' . $community); ?>" alt="<?php the_title(); ?>"></div>
On the main taxonomy archive, I can display this image like so:
$community = get_field('display_apartment_feed_for');
<img src="<?php the_field('community_logo', 'location_' . $community); ?>" alt="<?php the_title(); ?>">
Can you see what I’m doing incorrectly?
Thanks for your help!
Try doing a
var_dump($terms) … then
var_dump($custom_field) . What does it say?
So you’ll at least know where you get stuck.