i have 2 product_cat

Product cat 1 id : 6

Product cat 2 id : 8

in my index how to get product cat link with id or slug as:

<a href="Product cat 1 (link)">Product cat 1(name)</a>

<a href="Product cat 2 (link)">Product cat 2(name)</a>



Product category is just a regular wordpress taxonomy. You can get the link like this:

echo esc_url( get_term_link( 6, 'product_cat' ) );

You can use slugs too:

echo esc_url( get_term_link( 'category-slug', 'product_cat' ) );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.