Skip to main content

SEO tip: Fix hentry errors in Google Webmaster Tools

By May 12, 2015December 6th, 202017 Comments

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:

[php] /**
* Only use ‘hentry’ for post types with author and published date
function remaintenance_remove_hentry( $classes, $class, $post_id ) {
$hentry_post_types = array(

$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 );

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.