Home › Forums › General Issues › Display custom field (image) from parent category › Reply To: Display custom field (image) from parent category
Hello there!
I wrote a tutorial on my blog about that:
https://www.pushaune.com/blog/tutoriels/comment-recuperer-un-champ-acf-dune-categorie/
If you don’t speak french, here is the answer:
<?php $terms = get_the_terms( get_the_ID(), 'category');
if( !empty($terms) ) {
$term = array_pop($terms);
$custom_field = get_field('image_de_fond_de_categorie', $term );
$custom_field_text = get_field('texte_dintroduction', $term );
?>
<img src="<?php echo $custom_field; ?>"><!-- Afficher l'image de la catégorie -->
<?php echo $custom_field_text; ?><!-- Afficher le texte de la catégorie -->
<?php } ?>
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.