Skip to content

Instantly share code, notes, and snippets.

@imelgrat
Last active February 9, 2018 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imelgrat/4c187cc6652e22384b115330b6b73f8c to your computer and use it in GitHub Desktop.
Save imelgrat/4c187cc6652e22384b115330b6b73f8c to your computer and use it in GitHub Desktop.
Easy fix to remove 'hentry' CSS class from the post_class() list in WordPress posts
<?php
/**
* @author Ivan Melgrati
* @copyright 2018
*/
/**
* Easy fix to remove 'hentry' from the post_class() list
*
* By adding this code to your theme's functions.php file you will prevent
* the hEntry CSS class from being inserted into your posts.
* This will remove the structure of hAtom microformat which in turn prevent
* errors in Google' Structured Data Testing Tool.
*
* @see https://imelgrat.me/wordpress/hentry-fix-errors-wordpress/ for a full article on hEntry errors and fixes
*/
function imelgrat_remove_hentry($class)
{
$class = array_diff($class, array('hentry'));
return $class;
}
add_filter('post_class', 'imelgrat_remove_hentry');
?>
@imelgrat
Copy link
Author

imelgrat commented Feb 9, 2018

Simple WordPress filter to remove "hentry" class from all posts and pages. Dirty fix to avoid Search Console errors. See https://imelgrat.me/wordpress/hentry-fix-errors-wordpress/ for better solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment