Google’s Structured Data Testing Tool is strictly interpreting the use of the hentry
class.
The hentry
class is for date-stamped content intended to be syndicated, like blog posts. WordPress automatically adds the hentry
class with the post_class
function. Often post_class
is used in templates like this:
php the_ID(); ?>" <!--?php post_class(); ?-->>
Image may be NSFW.
Clik here to view.Many WordPress themes, even WordPress default themes, use
post_class
on all content, including pages. WordPress pages, as opposed to posts, don’t usually include a date and author because pages are not date based. Google’s Structured Data Testing Tool sees the hentry
class and expects to see date and author, so it lists errors. When Google lists errors, webmasters pay attention.
Remove WordPress hentry Class from Pages
To remove the hentry
post class only from pages, this can be added to your theme’s functions.php:
function themeslug_remove_hentry( $classes ) { if ( is_page() ) { $classes = array_diff( $classes, array( 'hentry' ) ); } return $classes; } add_filter( 'post_class','themeslug_remove_hentry' );
The screen grab below shows an example of how items with errors in the structured data report in Google Webmaster Tools drops to zero after removing the hentry
post class.
Image may be NSFW.
Clik here to view.
Should the WordPress core stop adding the hentry
class to pages to satisfy Google’s strict interpretation of structured data?
The post Remove WordPress hentry Class from Pages appeared first on Swamp-Side Studio.