I´m trying to display a custom taxonomy image in the frontend on a single post.
Following situation:
- Created a CPT for "Weine"
- Added a taxonomy "winzer"
- Added the following code to my functions.php to display the "winemaker" taxonomy with its description in the single post using a shortcode:
function wpb_catlist_desc() {
$string = '<div>';
$catlist = get_terms( 'winzer' );
if ( ! empty( $catlist ) ) {
foreach ( $catlist as $key => $item ) {
$string .= '<div>'. $item->name . '<br />';
$string .= '<em>'. $item->description . '</em></div>';
}
}
$string .= '</div>';
return $string;
}
add_shortcode('wpb_categories', 'wpb_catlist_desc');
- Added an Image fieled to the "winzer" taxonomy using ACF. –> Here´s where I´m stuck now.
I need to add another line to the php snippet to also display the image using the shortcode.
Any hints how to get this done? 🙂
Cheers!!!!
2
Answers
Here's how I got it solved: