-2

How to share a wordpress post having an animated gif as thumbnail image on facebook and, the new post on facebook, having a link back to the site (not the image)?

Wordpress uses "Yoast Wordpress SEO" plugin.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ivan Buttinoni
  • 4,110
  • 1
  • 24
  • 44

1 Answers1

0

Simply set the canonincal url of the post to the image.

function custom_canonical($original=null){
    global $post;
    $size = 'downsized-large'; // your preferred size
    if (has_post_thumbnail() == false) {
        return $original;
    }
    $url = get_the_post_thumbnail_url($post, $size);
    if (preg_match('/.gif$/i', $url)==false) {
        return $original;
    }
    return $url;
}

add_filter('wpseo_canonical', 'custom_canonical',1);

Add at the end of "functions.php" under the theme dir.

Ivan Buttinoni
  • 4,110
  • 1
  • 24
  • 44