post_class()
is a wrapper around get_post_class()
.
Try the following hook post_class
which is fired from get_post_class()
within wp-includes/post-template.php
:
add_filter('post_class', 'filter_post_class', 10, 3);
function filter_post_class($classes, $class, $post_id) {
$temp = implode(' ', $classes);
$temp = preg_replace('/\s\btag\-\w*\b/i', '', $temp);
return explode(' ', $temp);
}
Alternatively (RECOMMENED):
add_filter('post_class', 'filter_post_class', 10, 3);
function filter_post_class($classes, $class, $post_id) {
$classes = array_filter($classes, function($class_name){
// use !== 0 to ensure we match tag- at begining of string
return strpos($class_name, 'tag-') !== 0;
});
return $classes;
}
Another alternative method, although potentially with risks, is to:
add_filter('get_the_tags', 'filter_get_the_tags');
function filter_get_the_tags() {
return array();
}
Although with this approach some conditional logic should be considered within the callback.
I say that for the latter because the only other function (in terms of core WP) that calls get_the_tags()
is wp-includes/feed.php
and inparticular get_the_category_rss()
.