Home › Forums › Front-end Issues › Display image
Hi everybody,
Sorry for my English cause i’m French 😉
So, i’ve a little problem to display an custom taxonomy image in custom archive page.
I use this code to display it
<?php
$args = array( 'hide_empty' => 0,
'parent' => 0,
);
$terms = get_terms( 'taxonomy_ascenseur', $args );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
echo '<ul>';
foreach ( $terms as $term ) {
echo '<li><img src="'. the_field("image_categorie",$term) .'"/>' . $term->name . '</li>';
}
echo '</ul>';
}
?>
But it no displaying an image but just the url outside the “img” balise.
It display Something like this :
<ul>
http://localhost:8888/website/wp-content/uploads/2015/11/ascenseur2.jpg
<li>
<img src="">
Cat1
</li>
</ul>
I don’t understand why because if i put the image url directly in the <img src="" />
it work.
You’re not using the correct id for the field
<?php
$args = array(
'hide_empty' => 0,
'parent' => 0,
);
$terms = get_terms( 'taxonomy_ascenseur', $args );
if (!empty($terms) && !is_wp_error($terms)) {
echo '<ul>';
foreach ( $terms as $term ) {
echo '<li><img src="'.
the_field('image_categorie', 'taxonomy_ascenseur_'.$term->term_id).
'"/>'.$term->name.'</li>';
}
echo '</ul>';
}
?>
In the future you should not reply to your own question. Doing so takes it off the list of question that need a reply so it looks like someone is already helping you. Bumping questions won’t get them answered faster and doing so will hurt your chances of getting a reply.
You must be logged in to reply to this topic.
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!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.