Reputation: 97
I want this image to show on my frontend.
Kindly help me out. Thanks
Upvotes: 1
Views: 776
Reputation: 255
Try this code:
<?php
$categories = get_the_category();
foreach ( $categories as $category ) {
echo '<img src="' . esc_url( 'http://example.com/images/' . intval( $category-
>term_id ) . '.jpg' ) . '" alt="' . esc_attr( $category->name ) . '" />';
}
?>
Upvotes: 1