Home › Forums › General Issues › Display a Category Featured Image INSIDE a Post › Reply To: Display a Category Featured Image INSIDE a Post
Here’s where I think I am headed… about to go test a bit. Feel like I am missing something. This was inspired by multiple bits of documentation plus this post from 2019 w John’s reply
<?php
$categories= get_the_category();
if (!empty($categories)) {
$term_id = $categories[0]->term_id;
$image = get_field('category_logo_version_2', 'term_'.$term_id);
// what you do from here depends on what the field is returning
}
?>
// my educated guess at what I need to do next
<?php if( get_field('category_logo_version_2') ): ?>
// ACF is set to return the URL for this field thus no need for ['url'] before semicolon
<img class='center-image-w-css-later' src="<?php the_field('category_logo_version_2'); ?>" />
<?php endif; ?>
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.