Fixing Google snippet errors on wordpress platformsRecently I have been receiving many questions on Google’s Rich Snippets Testing Tool. Many are frustrated with the errors when previewing their snippets, getting common errors such as the 3 lines below. However do note that fixing this may not be straightforward because different themes different codes. As such, this how-to guide can only serve as a guideline. This solution is for WordPress only. Depending on your theme, you will need to modify either single.php, post.php or page.php. Similar because the author of your theme may code it differently. Remember to backup first.

Snippet Errors:
Warning: Missing required field “entry-title”.
Warning: Missing required field “updated”.
Warning: Missing required hCard “author”.

For the missing field entry-title:
<?php if ( get_the_title() ): ?>
<h1><?php the_title(); ?></h1>
<?php endif; ?>

And replace the line in bold with this:

<h1 class=”title entry-title”><?php the_title(); ?></h1>

For the missing field updated:
The error occurs because Google snippet wanted to know when was the post updated, so you have to search for the line containing the string “<?php the_date();?>”, and modify the line to look as below:

<div class=”date updated”>
Published on <?php the_time(‘F S, Y’); ?>
</div>

For the missing field hCard author:
This is more tricky as you need to include the elements from hCard microformat which are “vcard” and “fn”. Find the string <?php the_author(); ?>, and modify the code accordingly.

<span class=”vcard author”><span class=”fn”><?php the_author(); ?></span></span>

After fixing up, the snippet tool should show something like this:

Fixing the warning messages from Google snippet tool

I understand that this codes may not work for everyone, but it’s the basis for solving the snippets errors. Hopefully it can give you some clues to fix it for the theme you are using. I’m on the look out for a permanent solution otherwise whenever the theme I’m using upgrades, I have to re-edit the codes again.

If you want to validate your snippet in double quick time, you could install a bookmarklet that’s done by AJ Khon, you can read his post and find out more here.

Do you have a different alternative that worked for you?

FOLLOW

lincoln

Lincoln is a fan of Apple products, loves red wine and traveling. He blogs on internet marketing, social media, wordpress tips & guides, and using technology to maximize efficiency. Follow him on Twitter or Facebook for regular updates.
FOLLOW

8 Responses to How to Fix Google Rich Snippets Errors for WordPress

  1. Good tricks but Rich Snippets Testing Tool does not seem to take HTML update in real time… so it could be difficult understand what to do.

  2. Chellie says:

    Thank you so MUCH. I have a few sites and all were OK except one. I’ve spend a lot of time trying to resolve the error since I do not have a standard theme and your post did the trick. The instructions were clear and easy to follow.

  3. lincoln says:

    Cool, glad you finally got it to work :)

  4. DrewAPicture says:

    Thanks for the suggestions. In TwentyEleven I also had to go into all of the content-{format} template parts to fix updated dates, but it was nice to be able to clear the Snippets errors. Cheers!

  5. lincoln says:

    Thanks for the tip on TwentyEleven theme. If only Google released an easier way to get authorship recognized and authorized.

  6. I am getting same warning for my website “www.localapps.co”
    “Warning: Missing required field “updated”.”

    I am using the Genesis Child theme. And posts are handled directly by Genesis. I tried the above mentioned procedure using Genesis Hooks (add_filter( ‘genesis_post_info’, ‘post_info_filter’ );).
    But I am unable to solve the issue. Can you help me in this regard?

  7. Giu says:

    any idea on hows to apply this to canvas theme ?

Leave a Reply

Your email address will not be published. Required fields are marked *