Removes hentry class entries from Wordpress pages, categories and tags. SEO benefits for the website: eliminate related errors from Google Search Console > Structured Data > hatom (markup: microformats.org)
Wordpress core reports hentries for all pages to search engines. This causes SEO markup errors for non-posts whose authors or creation / update dates are irrelevant.
Developers, webmasters, SEO and Content specialists and practioners that want to fix errors found on Google Search Console > Search Appearance > Structured Data: hatom (markup: microformats.org):
- usually, it will list as errors all the pages, category and tag URLs in a Wordpress website
This codes removes hentries from all Wordpress pages, category and tag URLs so in a matter of days Google Search Console no longer reports errors.
- Add the code below to your functions.php file
- Over the next few days, test your pages using the Google’s Structured Data Testing Tool or Google Search Console on the following path: Search Appearance > Structured Data.
function themeslug_remove_hentry( $classes ) {
if ( is_page() OR is_category() OR is_tag()) {
$classes = array_diff( $classes, array( 'hentry' ) );
}
return $classes;
}
add_filter( 'post_class','themeslug_remove_hentry' );
This chart shows how Google Search Console processes existing errors in a matter of days: decrease on the next day and full solution in 2-3 weeks typically).
- Remove WordPress hentry Class from Pages provided the basic code to implement these changes, updated to extend coverage to category and tag pages
- Conditional Tags on Wordpress containing many examples
- This is how it's NOT done
Leave a comment! Thanks for reading and using this.
- Implement schema using Google Tag Manager Reference While the code above removes errors, it doesn't improves SEO. I'll look into it and provide guidance here shortly.