Home » Coding

[wp snippet] Get category link by name

31 March 2011 No Comment

Can be used like this:
<a href="<?PHP echo get_category_link_by_name('my category'); ?>">My category link</a>
And change “my category” to whatever you want.

Put this in functions.php

function get_category_link_by_name($cat){
//By http://0xA.li
$cat_ID = get_cat_ID($cat);
$cat_link = get_category_link($cat_ID);
$return $cat_link;
print $return;

Your opinion matters!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.