If you are using WordPress, you could be hindering your SEO with invalid structured data.
To quickly find out if you are getting hentry errors, log into Google Webmaster Tools and look at “Search Appearance” > “Structured Data”.
Look at the data type ‘hentry’. Are you getting errors? Then read on for the fix!
(NB: in the Google Structured Data Testing Tool this does not show up as an error!)
About hentry: here be content
“hentry” is a class that is added automatically by WordPress to the block on your page that contains the post. It is part of the hAtom specification, and indicates to search engines that there is content that can be syndicated. In other words: ‘this block contains an article that can be displayed in feeds‘.
In order for search engines and other bots to extract the article, they need to find at least the title, content, author and publishing date. These are indicated by their own classes ( entry-title
, entry-content
, author
, and published
respectively).
Most themes will use the classes above to indicate to bots what piece of content is what exactly, so they can read the page more easily.
The problem
The fields listed above are required for a hentry to be parsed. But Pages generally don’t display the author and published date!
WordPress adds the hentry
class automatically when the theme uses post_class()
, regardless of post type. Some theme authors refrain from using post_class()
for post types that are not blog posts, others use the trick below to prevent hentry to be added to Pages.
If you are getting the error, your theme probably does no such thing!
The solution
The solution is to disable hentry altogether for post types that do no sport an author or date.
Add the following snippet to your child theme functions.php
or your functions plugin:
* Only use ‘hentry’ for post types with author and published date
*/
function remaintenance_remove_hentry( $classes, $class, $post_id ) {
$hentry_post_types = array(
“post”
);
$post_type = get_post_type( $post_id );
if ( !in_array( $post_type, $hentry_post_types ) ) {
$classes = array_diff( $classes, array( ‘hentry’ ) );
}
return $classes;
}
add_filter( ‘post_class’, ‘remaintenance_remove_hentry’, 10, 3 );
[/php]
You can add extra post types to $hentry_post_types
to add hentry to other post types too.
Getting errors for blogs too?
If you are getting the error for blogs too, that means that the author and published classes are not added to posts! To fix this, you can disable hentry for posts as well, by remove post
from $hentry_post_types
in the above snippet.
Alternatively, you can fix your (child)theme by adding the author
and published
classes to your single.php
Don’t want to worry about how WordPress internals hinder your SEO performance? Contact Keetrax! We will pro-actively monitor your website for any performance and SEO issues, and solve things as they come up, so you can focus on your content.
How to add author etc. to pages in the Twenty Fourteen theme?
done with folow this article… thanks…
you are saying solution is for wordpress i want to know about blogger please give solution for solving structured data errors in blogger.
Hi friend, Im also getting this error, I tried but i couldn’t solve. Can you tell the solution for me.
Structured Data
Status: 1/28/17
31 Items with Errors
on 17 pages
Data Type Source Pages Items Items with Errors
hentry Markup: microformats.org 17 31 31
LaptopStore Markup: schema.org 67 67 –
LaptopShop Markup: schema.org 11 11 –
WebSite Markup: schema.org 1 11 –
hcard Markup: microformats.org 1 11 –
Thanks
Lenovo Service
thanks for sharing great article with us. it is very help ful for me.
Very nice article, helped me a lot, thanks for sharing,what about my website: businessandlifeonline.com , will try its best to bring high quality blogs which can help working employees like you to start your online business initially with out quitting your job and then be your own boss as your business grows.
Can you tell me how to do it in blogger blogs?
where to add author in single.php
I am working on a software solution and technology related blog website and google webmaster showing the same errors. This is really a nice article and helped me a lot to resolve this error from my website. Thanks for sharing…
Thanks for sharing you ideas with us.
Its very useful, I was able to fix one of blog. Thanks for sharing the nice article .
I got huge items with error in structured data, unfortunately i’m not familiar with coding, Any help?
Hello, I changed hentry and authour code in single.php but again it’s showing errors. when I doing testing on google webmaster then they are showing it is correct but again and again structure data are showing missing entry-title and missing author. how can I solve it?
Is there any way to fix Hentry or hatom errors with any plugin??
I have the same problem !
and the offered solution didn’t solve that !
Really, Very useful and informative article! Thanks for sharing such a wonderful article.
As my blog is in blogspot then how do i solve it.
Missing: author
Missing: updated
There is showing 22 error. I am new in coding so tell me easy way to solve it and also tell if any plugin for blogger.