Found a great snippet today on the WordPress forums for retrieving the url for the current category. Was useful in creating a lead into a category from a featured post on a homepage. See it in action in the News box on Jwitty Spirits. And pick up a bottle of organic liquer while you’re there!
<?php $the_cat = get_the_category(); $category_name = $the_cat[0]->cat_name; $category_description = $the_cat[0]->category_description; $category_link = get_category_link( $the_cat[0]->cat_ID ); ?> <a href="<?php echo $category_link; ?>" class="category_logo">Read More...</a>
This tip saved my day, man!
Thank you very much!
Your welcome Christopher. Happy coding! q:)
Awesome little snippet, its a really useful new function wonder why it isnt on the reference list yet :)
Be carrefull, this snipet doesn’t work if the first post of your loop is in multiple categories ! WordPress will take the first catégory and it can be another than the current category.
Good point, Shain. This would only be useful in a fairly simple site where posts didn’t wind up in multiple categories.