Skip to content

Instantly share code, notes, and snippets.

@seanbash
Created September 3, 2013 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanbash/6424907 to your computer and use it in GitHub Desktop.
Save seanbash/6424907 to your computer and use it in GitHub Desktop.
If there is a featured image in a wordpress post, then declare that as the article's thumbnail, otherwise use the website's main logo as the thumbnail.
<span itemscope itemtype='http://schema.org/Article'>
<?php $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
$feat = $large_image_url[0];
$my_excerpt = get_the_excerpt();
if(empty($feat))
{
$feat = "yourwebsitelogo.jpg";
}
echo "<meta content='$feat' itemprop='thumbnailUrl' />"; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment