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.
The topic ‘Display image’ is closed to new replies.
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.