我在我的网站上做了 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 } ?>
对不起我的英语不好