Skip to content

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)

Notifications You must be signed in to change notification settings

andpiazza/remove_hentry_wordpress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

remove_hentry_wordpress

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)

Problems this code solves

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.

Who's This For

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

The Solution

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.

Instructions - How to Apply and Customize this Code to Your Needs

  1. Add the code below to your functions.php file
  2. 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' );

Sample Results

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).

Credit and References

  1. Remove WordPress hentry Class from Pages provided the basic code to implement these changes, updated to extend coverage to category and tag pages
  2. Conditional Tags on Wordpress containing many examples
  3. This is how it's NOT done

Want to provide feedback or contribute?

Leave a comment! Thanks for reading and using this.

Future Developments

  1. 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.

About

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)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published