Advertisement
Guest User

Open Graph Meta

a guest
Dec 4th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { ?>
  2. <?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'mvp-post-thumb' ); ?>
  3. <meta property="og:image" content="<?php echo esc_url( $thumb['0'] ); ?>" />
  4. <meta name="twitter:image" content="<?php echo esc_url( $thumb['0'] ); ?>" />
  5. <?php } ?>
  6.  
  7. <?php if ( is_single() ) { ?>
  8. <meta property="og:type" content="article" />
  9. <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  10. <meta property="og:description" content="<?php echo strip_tags(get_the_excerpt()); ?>" />
  11. <meta name="twitter:card" content="summary">
  12. <meta name="twitter:url" content="<?php the_permalink() ?>">
  13. <meta name="twitter:title" content="<?php the_title(); ?>">
  14. <meta name="twitter:description" content="<?php echo strip_tags(get_the_excerpt()); ?>">
  15. <?php endwhile; endif; ?>
  16. <?php } else { ?>
  17. <meta property="og:description" content="<?php bloginfo('description'); ?>" />
  18. <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement