【问题标题】:Wrong og:image in the Facebook Open GraphFacebook Open Graph 中的 og:image 错误
【发布时间】:2013-02-10 04:15:57
【问题描述】:

我在我的网站上做了 Open Graph,一切都很完美。

但是,对于主页(front_page),facebook 会拍摄 FOOTER 的图像(?!)

在调试中是好的。如何强制 facebook 将 OG: IMAGE 作为第一张图片?

代码:

<?php if (have_posts()):while(have_posts()):the_post(); endwhile; endif;?>
<!-- the default values -->
<meta property="fb:app_id" content="MY ID" />

<!-- if page is home -->
<?php if (is_front_page()) { ?>
<meta property="og:title" content="name" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://www.com/"/>
<meta property="og:image" content="http://www.com/wp-content/uploads/2013/02/thumbface.jpg" /> <?php } ?>

<!-- if page is content page -->
<?php if (is_single()) { ?>
<meta property="og:title" content="<?php single_post_title(''); ?>" />
<meta property="og:type" content="article" />
<meta property="og:url" content="<?php the_permalink() ?>"/>
<meta property="og:description" content="<?php echo strip_tags(get_the_content($post->ID)); ?>" />
<meta property="og:image" content="<?php $fbthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'facebook-thumb' ); echo $fbthumb[0]; ?>" />

<!-- if page is others -->
<?php } else { ?>
<meta property="og:site_name" content="<?php bloginfo('name'); ?>" />
<meta property="og:description" content="<?php bloginfo('description'); ?>" />
<meta property="og:image" content="http://www.com/wp-content/uploads/2013/02/thumbface.jpg" /> <?php } ?>

抱歉我的英语不好

【问题讨论】:

    标签: facebook wordpress facebook-opengraph


    【解决方案1】:

    Facebook's Debug Tool 上调试 URL。即使图片是正确的,您的 URL 也有可能已被 Facebook 缓存。使用 Linter 将删除缓存,并使用页面上当前可用的标签。

    【讨论】:

    • 在DEBUG中就可以了。它显示了正确的图像。但是当我将 LINK 放在 facebook 上时,它会显示 og: image 作为最后一个选项。第一个选项是 FOOTER 的图片。谢谢。
    • 是的。尽管在选择缩略图时正确的图像显示为第三个选项。我认为当用户喜欢该页面时 og:image 效果很好。在共享的情况下,向用户显示选项。我建议你尝试两件事:1)使用超过 1 个 og:image 标签,看看会发生什么。 2)在页脚之后使用正确的图像并将其设置为隐藏。也许FB也会解析。
    猜你喜欢
    • 2013-06-22
    • 1970-01-01
    • 1970-01-01
    • 2015-04-19
    • 2012-02-21
    • 2011-12-13
    • 1970-01-01
    • 1970-01-01
    • 2015-08-29
    相关资源
    最近更新 更多