Feb
27
I was working on a theme and i faced that problem , i wanted to get dynamically the category link using category names and there’s no function in wordpress to do that , so i’ve wrote a simple function that does what i need .
I’ve used get_cat_ID function to get category id using name , then get_category_link function to get category link using category id , very simple .
function get_category_link_byname($name) {
$id = get_cat_ID($name);
$link = get_category_link( $id );
echo $link;
}
use this function as follows ,
<?php function get_category_link_byname('categoryname'); ?>
and that’s it , hope you find it useful .



Leave Your Own Comment on This Post