How to fix “A value for the logo field is required” via Google’s Rich Snippets Tool

So you’re getting this annoying error. You’ve researched Schema.org’s website…no help. You’ve read a bunch of Stackoverflow articles…still no help.

Firstly, note that Schema.org and Google’s Rich Snippet Testing Tool are not universally linked. That is, just because something is valid according to Schema.org, it may not meet Google’s own requirements.

For an Article type, here is Google’s exact code, which will validate the Rich Snippet Testing Tool:

<div itemscope itemtype="http://schema.org/NewsArticle">
<meta itemscope itemprop="mainEntityOfPage" itemType="https://schema.org/WebPage" itemid="https://google.com/article"/>
<h2 itemprop="headline">Article headline</h2>
<h3 itemprop="author" itemscope itemtype="https://schema.org/Person">
By <span itemprop="name">John Doe</span>
</h3>
<span itemprop="description">A most wonderful article</span>
<div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
<img src="https://google.com/thumbnail1.jpg"/>
<meta itemprop="url" content="https://google.com/thumbnail1.jpg">
<meta itemprop="width" content="800">
<meta itemprop="height" content="800">
</div>
<div itemprop="publisher" itemscope itemtype="https://schema.org/Organization">
<div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject">
<img src="https://google.com/logo.jpg"/>
<meta itemprop="url" content="https://google.com/logo.jpg">
<meta itemprop="width" content="600">
<meta itemprop="height" content="60">
</div>
<meta itemprop="name" content="Google">
</div>
<meta itemprop="datePublished" content="2015-02-05T08:00:00+08:00"/>
<meta itemprop="dateModified" content="2015-02-05T09:20:00+08:00"/>
</div>

That comes straight from Google’s mouth.

What if you want to do this in WordPress though? Here’s the code you’ll want:

<div itemscope itemtype="http://schema.org/NewsArticle">
<meta itemscope itemprop="mainEntityOfPage" itemType="https://schema.org/WebPage"/>
<h2 itemprop="headline"><? the_title(); ?></h2>
<h3 itemprop="author" itemscope itemtype="https://schema.org/Person">
By <span itemprop="name"><?php echo get_the_author_meta( 'first_name' ); ?> <?php echo get_the_author_meta( 'last_name' ); ?></span>
</h3>
<span itemprop="description">< the_excerpt(); ?></span>
<div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
<meta itemprop="url" content="<?php the_post_thumbnail_url( 'full' ); ?>">
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "thumbnail" );
$thumb_width = $thumb[1];
$thumb_height = $thumb[2]; ?>
<meta itemprop="width" content="<?php echo $thumb_width; ?>">
<meta itemprop="height" content="<?php echo $thumb_height; ?>">
</div>
<div itemprop="publisher" itemscope itemtype="https://schema.org/Organization">
<div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject">
<!--<img src="https://google.com/logo.jpg"/> // you could add a real logo here, but it's not necessary -->
<meta itemprop="url" content="[A URL TO YOUR LOGO HERE, should fit into a 160px x 60px box]">
<meta itemprop="width" content="[enter the width of the logo here]">
<meta itemprop="height" content="[enter the height of the logo here]">
</div>
<meta itemprop="name" content="<?php echo get_bloginfo('name'); ?>">
</div>
<?php $modified_date = get_the_modified_date('Y-m-d');
$publish_date = get_the_date('Y-m-d'); ?>

<meta itemprop="datePublished" content="<?php echo $publish_date; ?>"/>
<meta itemprop="dateModified" content="<?php echo $modified_date; ?>"/>
</div>

Up Next: How to Remove Mysterious White Space When URLEncoding get_the_excerpt()