What happens when there’s more then one category, you’ll end with a long line of text from all the matched categories as class name..
This would be fine, grabs the first category, then unsets the unused data..
<h2 class="<?php $cat = get_the_category(); echo $cat[0]->cat_slug; unset($cat); ?>"><?php prox_cat_link($post_by_cat); //category title as a link to category archive ?></h2>
Also not sure why you’re doing this…
<?php prox_cat_link($post_by_cat); //category title as a link to category archive ?>
There are functions for grabbing a category link… you could do this all like so….
<?php $cat = get_the_category(); ?>
<h2 class="<?php echo $cat[0]->slug;?>">
<a href="<?php echo get_category_link($cat[0]->cat_ID);?>">
<?php echo $cat[0]->cat_name; ?>
</a>
</h2>
<?php unset($cat); ?>
Uses the slug for the class name (i don’t know about anyone else but i use very simple slugs, so this seemed an obvious choice – faster then having to “strtolower” etc..)…
Uses the ID to grab the link used in the link element..
Uses cat name for the link text…
Then at the end unsets the data so it’s not floating around…