Making featured images clickable
-
Hello,
I want to make my featured images clickable so they would be a link to the post page. I have used the following function (in a child theme, of course).<?php add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 ); function my_post_image_html( $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; } ?>
The problem is that once I’m in the post, the featured image STILL link to the post page!
How do I make the featured image link behave like the post title that cancels the link once the reader is in the post page?Thank you!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Making featured images clickable’ is closed to new replies.