Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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?

    #850825

    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

    #850951

    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!

    • This reply was modified 7 years, 3 months ago by ecdoesit.
    #851020

    Hi ecdoesit,

    There is an error in this code, did it work for you?

    Best regards,
    Victoria

    #851060

    Hi Victoria,

    It did, but also ended up affecting the “Related Posts” images at the bottom, messing that up a bit.

    #851156

    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!

    #851195

    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!

    #851359

    Hi,

    Great, glad you found the problem and thanks for letting us know. Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.