The categories and tags are in the array that builds the post_class in post-template.php.
I want to use post_class and love having the ability to add classes, but am stuck trying to remove the tags and categories.
Anyone know how to remove those two without hacking the core?
SimonBoba
Member
Posted 2 years ago #
Hi.
Write this instead of post_class in your template:
<?php
$post_classes = get_post_class();
foreach ($post_classes as $key => $value) {
$pos = strripos($value, 'tag-');
if ($pos !== false) {
unset($post_classes[$i]);
}
}
$post_classes= implode(' ', $post_classes);
echo 'class="'.$post_classes.'"';
?>
Not the most elegant solution, but it does the job. If you want to remove categories too, just do the same thing with 'category-' in the loop.
Cheers - I'm actually filtering out all dynamic classes now as they accounted for an increase of 50% in file sizes on my themes.