-
AuthorPosts
-
September 12, 2017 at 4:08 am #850731
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?
September 12, 2017 at 8:03 am #850825Hey ecdoesit,
It looks like the image is already linking to the post. Were you able to get this figured out?
Best regards,
Jordan ShannonSeptember 12, 2017 at 11:24 am #850951Hi 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!
-
This reply was modified 8 years, 2 months ago by
ecdoesit.
September 12, 2017 at 2:38 pm #851020Hi ecdoesit,
There is an error in this code, did it work for you?
Best regards,
VictoriaSeptember 12, 2017 at 4:06 pm #851060Hi Victoria,
It did, but also ended up affecting the “Related Posts” images at the bottom, messing that up a bit.
September 12, 2017 at 6:23 pm #851156Anyone 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!
September 12, 2017 at 7:12 pm #851195Yikes, 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!
September 13, 2017 at 5:48 am #851359 -
This reply was modified 8 years, 2 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.
