Skip to content

Instantly share code, notes, and snippets.

@chrisvanpatten
Created June 21, 2013 18:03
Show Gist options
  • Select an option

  • Save chrisvanpatten/5833078 to your computer and use it in GitHub Desktop.

Select an option

Save chrisvanpatten/5833078 to your computer and use it in GitHub Desktop.
Quick OpenGraph/meta tags.
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@TwitterHandle">
<meta name="twitter:creator" content="@TwitterHandle">
<meta property="og:locale" content="en_US">
<meta property="og:site_name" content="<?php get_bloginfo('title'); ?>">
<?php if ( is_single() || is_page() ) : ?>
<meta property="og:title" content="<?php wp_title(''); ?>">
<meta property="og:url" content="<?php echo get_permalink(); ?>">
<meta property="og:image" content="<?php
if ( has_post_thumbnail() ) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail' );
echo $image[0];
}
?>">
<meta property="og:type" content="article">
<meta property="og:description" content="<?php echo wp_trim_words( get_excerpt_by_id($post->ID), 20 ); ?>">
<?php else : ?>
<meta property="og:title" content="<?php echo get_bloginfo('title'); ?>">
<meta property="og:url" content="<?php echo get_bloginfo('url'); ?>">
<meta property="og:type" content="website">
<meta property="og:description" content="Your description.">
<meta name="description" content="Your description.">
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment