Recently 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.
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’); ?>
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:
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?
Latest posts by lincoln (see all)
- Twitter Search Operators for Geeks – Change the Way You Search - April 21, 2016
- How to Auto Publish from Instagram to WordPress Using Instagrate - April 19, 2016
- 20 Best Ways to Use Twitter Advanced Search to Find Leads - April 17, 2016