Posted on Jul 28, 2009

WordPress Blown: get current category link

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>