Display link to category over featured image

Question

I managed to get the category to display in the corner of the featured image but what I want is for the function to be a link and not just the name. I’m sure this is deadly simple but my google-fu is defeating me.

add_filter( 'post_thumbnail_html','tu_add_category_featured_image' );
function tu_add_category_featured_image( $output ) {
 $return = $output;
 $cat = get_the_category( get_the_ID() );
 if ( isset( $cat ) && ! is_singular() ) {
     foreach( $cat as $cat_name ) {
         $return .= '<div class="featured-image-category">' . $cat_name->name . '</div>';
     }
 }
 
 return $return;
}
0
shelikeskites 1 month 0 Answers 7 views 0

Leave an answer