Friday, 23 May 2014

Get Product Category Link By Category Name In woocommerce

Here is the function for category Link by Category Name in Woocommerce

function Nexp_woocommerce_product_cat_link($CatName){

$catTerms = get_terms( 'product_cat', array('hide_empty' => 0, 'orderby' => 'ASC'));
//print_r($catTerms);
foreach($catTerms as $catTerm) : 


if($catTerm->name == $CatName)
{

return get_term_link( $catTerm);


} 

endforeach;  


}

Place it in theme function.php file and call anywhere this function in the theme file.

Call the function :

$ProdCatLink = Nexp_woocommerce_product_cat_link("Fashion Jewellery");


0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home