I'm using ACF Taxonomy Images, and I can't display a category's image on a single-car.php

This is the code that I'm using to show brand image and country image in taxonomy.php :

$term = get_queried_object();
$brandimage = get_field('am-brand-img', $term);
$size = 'thumbnail';
$thumb = $brandimage['sizes'][ $size ];
$brandcountry = get_field('am-brandcountry', $term);
$brandcimage = get_field('am-brandcimage', $term);

<div class="brand-logo">
  <img src="<?php echo $thumb; ?>" alt="<?php echo $brandimage['alt']; ?>" width="100" height="100">

<div class="brand-country">
  <img src="<?php echo $brandcimage['url']; ?>" width="32" height="32">
  <p><?php echo $brandcountry; ?></p>

1 Answer 1


ChatGPT answer worked:

 $categories = get_the_terms(get_the_ID(), 'car-brand');

 if ($categories && !is_wp_error($categories)) {
     // Assuming you have only one category per post, you can use the first one
     $category = $categories[0];

     // Get the category image using ACF
     $category_image = get_field('am-brand-img', $category);
     $size = 'am-thumbnail';
     $category_thumb = $category_image['sizes'][$size];
     $category_country = get_field('am-brandcountry', $category);
     $category_cimage = get_field('am-brandcimage', $category);

     // Display the category image and details
     if ($category_thumb) {
         echo '<div class="brand-logo">';
         echo '<img src="' . $category_thumb . '" alt="' . $category_image['alt'] . '" width="100" height="100">';
         echo '</div>';

     if ($category_cimage && $category_country) {
         echo '<div class="brand-country">';
         echo '<img src="' . $category_cimage['url'] . '" width="32" height="32">';
         echo '<p>' . $category_country . '</p>';
         echo '</div>';
  • 1
    While AI generated posts aren't explicitly banned on the WP StackExchange (it is on StackOverflow however), this answer isn't very useful to anyone in the future who may have the same problem. There should be an explanation of what the code does in your answer, and how it solved your problem.
    – YourManDan
    Oct 26, 2023 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.