Home › Forums › General Issues › display my taxonomy's image and text fields on taxonomy term page
Hello, I have a taxonomy called Magazine, attached to my normal posts. I have added a few fields to the taxonomy, an image and a description (WYSIWYG field). The custom slug is “editions”.
On http://mysite.com/editions/damn-50/, I have all the posts attached to this taxonomy loading, but above that, I want to display the taxonomy image and description. I have followed instructions here: http://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/, but no luck.
Here is a screenshot of how I setup the ACF fields (image is an ID)
And my taxonomy edit screen
Here is how I would like to display the image and description
<article <?php post_class(”); ?>>
<div class=”col-xs-12 col-sm-6 col-md-5″>
<?php $magazineimage = wp_get_attachment_image_src(get_field(‘magazine_taxonomy_image’, ‘magazine_9049’), ‘full’); ?>
<?php echo $magazineimage; ?>
<div class=”col-xs-12 col-sm-6 col-md-7″>
<?php the_field(‘magazine_taxonomy_description’, ‘magazine_9049’); ?>
Please post code within code tags as it makes it so much easier to look at as well as copy etc.
Could you try this:
<?php $term = $wp_query->queried_object; ?> <?php the_field('magazine_taxonomy_description', $term->taxonomy . '_' . $term->term_id); ?>
Worked like a charm, thanks a lot!
here is my code for other people, with the same question, to reference
<?php $term = $wp_query->queried_object; ?> <article <?php post_class(''); ?>> <div class="entry-content"> <div class="row"> <div class="col-xs-12 col-sm-6 col-md-4"> <div class="post-image"> <?php $magazineimage = wp_get_attachment_image_src(get_field('magazine_taxonomy_image', $term->taxonomy . '_' . $term->term_id), 'full'); ?> <img src="<?php echo $magazineimage; ?>" alt="<?php echo get_the_title(get_field('magazine_taxonomy_image')) ?>" class="placeholder" /> </div> </div> <div class="col-xs-12 col-sm-6 col-md-8"> <?php the_field('magazine_taxonomy_description', $term->taxonomy . '_' . $term->term_id); ?> </div> </div> </div> </article>
Great 🙂 Would you please mark an answer so this topic is closed properly.
If you need help with ACF again don’t hesitate to post a new topic in the forums and we’ll try to help you out.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
The most recent ACF Chat Friday featured a live demo of how to register CPTs directly in the plugin, one of our most requested features. Check out the summary below for a replay of the demo, and don’t forget to register for the next session! https://t.co/k2KQ3WWBAz— Advanced Custom Fields (@wp_acf) March 9, 2023
© 2023 Advanced Custom Fields.