Advertisement
Deeproad

Wordpress open graph image tag

May 10th, 2014
7,224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php if (is_single()&& has_post_thumbnail()) { ?>
  2.  
  3.   <meta property="og:image" content="<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 300, 300 ), false, '' ); echo $src[0]; ?>" />
  4.   <meta property="og:image:width" content="200" />
  5.   <meta property="og:image:height" content="200" />
  6.  
  7. <?php }else{ ?>
  8.  
  9.   <meta property="og:image" content="<?php bloginfo('siteurl'); ?>/wp-content/themes/MyTheme/images/preview.jpg" />
  10.   <meta property="og:image:width" content="200" />
  11.   <meta property="og:image:height" content="200" />
  12.  
  13. <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement