Home › Forums › ACF PRO › Getting ACF field from a taxonomy in a page with WP_query › Reply To: Getting ACF field from a taxonomy in a page with WP_query
I finally found out the solution. I was wrong from the start. This code works for me, it can probably be optimized
<?php
$args = array(
'taxonomy' => 'marques-produits',
'orderby' => 'name',
'order' => 'ASC'
);
$cats = get_categories($args);
foreach($cats as $cat) {
if ($logo = get_field('logo_marque','marques-produits_'.$cat->term_id)) {
$cats_keep[] = $cat;
}
}
foreach($cats_keep as $cat) {
?>
<a href="<?php echo get_category_link( $cat->term_id ) ?>">
<img src="<?php echo esc_url($logo['url']); ?>" alt="<?php echo esc_attr($logo['alt']); ?>" />
</a>
<?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.