wordpress - Wrong og:image in the Facebook Open Graph -
i did open graph on website , perfect.
but, homepage (front_page), facebook takes image of footer (?!)
in debug alright. how forcefulness facebook create og: image first image?
the code:
<?php if (have_posts()):while(have_posts()):the_post(); endwhile; endif;?> <!-- default values --> <meta property="fb:app_id" content="my id" /> <!-- if page 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 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 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 } ?>
and sorry bad english
debug url on facebook's debug tool. there's possibility url has been cached facebook though image right one. using linter delete cache, , utilize presently available tags on page.
facebook wordpress opengraph
No comments:
Post a Comment