Guest User

Add OG:image meta to header in tribe event

a guest
Feb 26th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. add_action('wp_head', 'my_featured_fb_image');
  2.  
  3. function my_featured_fb_image($post_id = null, $size = 'full') {
  4. if(tribe_is_event() && is_single() ) {$post_id = get_the_ID();
  5. $image_src = get_post_thumbnail( $post_id , $size );
  6. $fb_meta_tag = '';
  7. if ( !empty( $image_src ) ) {
  8. $fb_meta_tag .= '<meta property="og:image" content="' . $image_src . '" >';
  9. echo $fb_meta_tag;
  10. }
  11. else {
  12. echo '<meta property="og:image" content="http://www.sciotomile.com/wp-content/uploads/2014/02/Default_Feature_Thumbnail.png"/>';
  13. }
  14. }}
Advertisement
Add Comment
Please, Sign In to add comment