doufan1899 2014-10-14 02:40 采纳率: 100%
浏览 30

为什么Facebook在Wordpress网站上分享不稳定?

I have a strange issue here.

A Wordpress site developed by us for a client, www.oasisplace.com.my has issues sharing blog posts.

In each blog post's bottom there is a Facebook sharing icon.

If clicked on the Facebook sharing dialog appears.

For some users, the featured image is replaced with the Facebook icon itself. For some others it is simply a blank image. However for me and a few of the development team, the post gets shared normally with visible featured image.

Is there anything that can be done to resolve this?

My assumption is something screwed up during the migration from a staging server (with different site URL) to the production server for official deployment.

Thanks.

  • 写回答

1条回答 默认 最新

  • duangang1991 2014-10-14 04:37
    关注

    If you include

    <link rel="image_src" href="http://www.oasisplace.com.my/path/to/image.jpg"/>
    

    or

    <meta property="og:image" content="[image url]"/>
    

    Facebook should pick it up consistently.

    Getting those things into the header on a WordPress site can be a pita.

    http://werewp.com/wordpress/how-to-integrate-facebook-open-graph-protocol-into-your-wordpress-theme/ uses a secondary loop inside of header.php (or wherever your <head> section is located). Seems inefficient but probably works.

    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" prefix="og: http://ogp.me/ns#" <?php language_attributes(); ?>>
    <?php if (have_posts()):while(have_posts()):the_post();endwhile;endif;?>
    >
    <?php if (is_single()) { ?>
        <meta property="og:title" content="<?php single_post_title(''); ?>" />
        <meta property="og:description" content="<?php echo strip_tags(get_the_excerpt($post->ID)); ?>" />
        <meta property="og:type" content="article" />
        <meta property="og:image" content="<?php echo wp_get_attachment_thumb_url( get_post_thumbnail_id( $post->ID ) ) ?>" />
    <?php } else { ?>
        <meta property="og:site_name" content="<?php bloginfo('name'); ?>" />
        <meta property="og:description" content="<?php bloginfo('description'); ?>" />
        <meta property="og:type" content="website" />
        <meta property="og:image" content="<?php bloginfo('template_url') ?>/path/to-your/logo.jpg" />
    <?php } ?>
    

    I've taken to including the Yoast SEO plugin on all sites I build these days. One of the reasons is that it handles the Facebook header stuff for us. It uses sensible defaults and allows you to overwrite those defaults on any given post.

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line