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>';
}
}