Last active
February 9, 2018 14:50
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.