Skip to content

Instantly share code, notes, and snippets.

@TheHeat
Created April 24, 2013 18:41
Show Gist options
  • Save TheHeat/5454460 to your computer and use it in GitHub Desktop.
Save TheHeat/5454460 to your computer and use it in GitHub Desktop.
Fire WordPress post info into a Twitter summary card.
function heat_twitter_card(){
$title = get_post_meta(get_queried_object_id(), 'Title', true);
$description = get_post_meta(get_queried_object_id(), 'Description', true);
$image = get_the_image(array('format'=>'array')); ?>
<!--Twitter Card-->
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@marcheatley">
<meta name="twitter:title" content="<?php echo $title; ?>">
<meta name="twitter:description" content="<?php echo $description; ?>">
<meta name="twitter:creator" content="@marcheatley">
<meta name="twitter:image:src" content="<?php echo $image[url]; ?>">
<?php }
add_action( 'wp_head', 'heat_twitter_card' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment