How would I go about changing a post’s featured image link to go to its respective post, rather than the image in a popup modal?
Hey ecdoesit,
It looks like the image is already linking to the post. Were you able to get this figured out?
Best regards,
Jordan Shannon
Hi Jordan,
Thank you for the reply. I used this filter in functions.php:
add_filter( 'post_thumbnail_html', 'wpb_autolink_featured_images', 10, 3 );
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;
}
but unfortunately that adversely affects the “Related Posts” section at the bottom. I’ve commented out that code for now. Any ideas?
Thanks!
Hi ecdoesit,
There is an error in this code, did it work for you?
Best regards,
Victoria
Hi Victoria,
It did, but also ended up affecting the “Related Posts” images at the bottom, messing that up a bit.
Anyone have an alternative solution that changes the featured image link to the post itself? I’m trying to figure out which theme template file generates the featured image but am having no luck. Thanks in advance!
Yikes, so I figured it out. The user was setting all their posts to a format of “image” rather than “standard”. My bad for overlooking it. Nevertheless, I appreciate the replies!