Can’t get taxonomy ID for each post on archive page

I’m trying to get an individual posts custom taxonomy ID to then print an image with ACF. I’ve looked at the documentation here on ACF and this support ticket too.

From my understanding it looks like it should work if if I use get_queried_object(), however I’m not having much luck.

Here is my code:

<?php $producers_assessment_object = get_queried_object();?>
<?php the_field(‘badge’, ‘producers_assessment_’ . $producers_assessment_object->term_id); ?>

If I manually put in the post ID like so the field works as I would like it to.

I’ve tried using this code below from another SO questions, just to see if I can the term Id in anyway and this also didn’t work.

$cate = get_queried_object();
$cateID = $cate->term_id;
echo $cateID;

Read more here:: Can’t get taxonomy ID for each post on archive page

Leave a Reply

Your email address will not be published. Required fields are marked *