Hyperlink on Features images


#1

Hi there,

I have the Features images section of the latest post on my website. I try to make the images clickable, so not just the title is clickable. I found a code and i inserted it in the function.php, but the image looks like clickable (pointer cursor) but doesn’t matter how many times or where I try to click on the image, is not click through. Any ideas?

This is a code I just did put in the function.php:
function wpb_autolink_featured_images( $html , $post_id , $post_image_id ) {

$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . $html . '</a>' ;

return $html ;

}

add_filter( 'post_thumbnail_html' , 'wpb_autolink_featured_images' , 10, 3 );


#3

I’d like to know the answer to this as well, please


#4

Hello there,

I tried that code and it works for plain featured image. For which has been uniquely styled as seen on Greatmag’s front page, like on this section, that code sin’t enough.

In order to help me get the exact code, please tell me on which part you’d like the image has a link to its post details. Also, please share a link to your site to help me more precise.

Regards,
Kharis


#5

Thanks Kharis for your response. I already solved the problem. Basically, the JS code was correct but because the image has a grey overlay on it, that layer stopped the cursor to click though. I changed the pointer-events on the anchor tag & the overlay and it is working perfectly.

Thanks again.


#6