Set Canonical URL to GIF for Facebook

I'm creating a gif hosting user frontend submission site. For Facebook to correctly animate a GIF on their platform

I'm creating a gif hosting user frontend submission site. For Facebook to correctly animate a GIF on their platform, the og meta tag needs to be redirected to the specific gif. I can remedy this by manually adding the gif url as the canonical link and it will work.

However, dynamic posts from multiple users, I will need to reference that gif as canonical in order for it to work.

What would be the best method to do this?

I'm creating a gif hosting user frontend submission site. For Facebook to correctly animate a GIF on their platform, the og meta tag needs to be redirected to the specific gif. I can remedy this by manually adding the gif url as the canonical link and it will work.

However, dynamic posts from multiple users, I will need to reference that gif as canonical in order for it to work.

What would be the best method to do this?

Share Improve this question asked May 21, 2020 at 23:51 user3011165user3011165 111 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

I learned that OG:URL tags can be the workaround and can work completely away from canonical links. That said I had to clean out an existing opengraph url that pointed to OG:URL and create a new one based on the posted thumbnail of the gif.

This was added to my function.php file

add_filter( 'wpseo_opengraph_url' , '__return_false' ); 
add_action('wp_head', 'dgsoft_fb'); function dgsoft_fb(){
if( is_single() ) {
         echo '<meta property="og:url" content="'. get_the_post_thumbnail_url(get_the_ID(),'full')   .'" />';
       } }

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742411066a4438821.html

相关推荐

  • Set Canonical URL to GIF for Facebook

    I'm creating a gif hosting user frontend submission site. For Facebook to correctly animate a GIF on their platform

    14小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信