One way would be to use preg_match
and remove classes that matches given patterns, but… Since we know $post_id
, we can use your code with a tiny modification:
function lsmwp_remove_postclasses($classes, $class, $post_id) {
$classes = array_diff( $classes, array(
'hentry',
'post-' . $post_id,
'type-' . get_post_type($post_id),
'status-' . get_post_status($post_id),
) );
return $classes;
}
add_filter('post_class', 'lsmwp_remove_postclasses', 10, 3);