简体   繁体   English

当 url 在 Linkedin 上共享时,Meta og 标签图像不会更新

[英]Meta og tag image is not updating when the url is shared on Linkedin

I'm facing a problem in my WordPress site, I have a url for which I'm trying to change the image which appears when the url is shared on social platforms.我的 WordPress 网站遇到问题,我有一个 url,我正在尝试更改该 url 在社交平台上共享时显示的图像。 The image is getting updated for all the social platform except Linkedin.除 Linkedin 外,所有社交平台的图像都在更新。

I have tried updating the image with meta:og tag but Linkedin still shows the older image.我尝试使用 meta:og 标签更新图像,但 Linkedin 仍显示旧图像。 Linkedin takes around 7 days for the cache to get cleared, but I have waited now for 1 month, still no update in Image. Linkedin 大约需要 7 天才能清除缓存,但我现在已经等了 1 个月,仍然没有更新 Image。

Wordpress offers a way by which custom images can be passed by AddToAny wordpress plugin, below is the code for that: Wordpress 提供了一种可以通过 AddToAny wordpress 插件传递自定义图像的方法,以下是其代码:

$img_src = wp_get_attachment_image_src(get_post_thumbnail_id($EM_Event->post_id));

// Pass custom image to AddtoAny plugin

if (function_exists('ADDTOANY_SHARE_SAVE_KIT')) {
    ADDTOANY_SHARE_SAVE_KIT(array(
        'linkmedia' => $img_src[0],
        'linkname'  => $EM_Event->event_name,
        'linkurl'   => get_the_permalink($EM_Event->post_id),
    ));
}

Even after passing the image via above code, I'm facing the same issue.即使通过上面的代码传递图像后,我也面临同样的问题。

Any help shared would be great!任何分享的帮助都会很棒! Thanks谢谢

You are right about the cache time: "...LinkedIn caches link preview content for 7 days."您对缓存时间的看法是正确的: “...LinkedIn 将链接预览内容缓存了 7 天。” (Source: LinkedIn: How to Clear LinkedIn Link Preview Cache .) (来源: LinkedIn:如何清除 LinkedIn 链接预览缓存。)

To refresh the cache, simply check your URL at the LinkedIn Post Inspector : This tool not only refreshes the cache, but it inspects the page code, shows possible values that were considered for title or summary , shows which was taken, and then explains why it made those decisions.要刷新缓存,只需在LinkedIn Post Inspector 上检查您的 URL:此工具不仅会刷新缓存,还会检查页面代码、显示考虑用于titlesummary可能值、显示已采用的值,然后解释原因它做出了这些决定。 Very useful for situations like this!对于这样的情况非常有用!

If you're still not certain, you can test by testing out the preview for example.com?test=1 instead of for example.com .如果您仍然不确定,您可以通过测试example.com?test=1而不是example.com的预览来进行测试。 Since the URL is technically different, but it's not a value being used by the page, it should miss the LinkedIn preview cache and generate a new preview.由于 URL 在技术上是不同的,但它不是页面正在使用的值,它应该会错过 LinkedIn 预览缓存并生成一个新的预览。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM