Marcel Gniotek
Marcel Gniotek

Reputation: 3

Woocommerce - link to category of products

I have problem with custom link to my specific category. I wanted to show in the link product cat "shoes", unfortunately the link does not work.

<?php $category_link = get_term_by('slug', 'product_cat', 'shoes'); ?> <a href="<?php echo esc_url( $category_link ); ?>" title="xxx">Shoes</a>

Upvotes: 0

Views: 4395

Answers (1)

darc1n
darc1n

Reputation: 306

You should use get_term_link(), like this:

$category_link = get_term_link('shoes', 'product_cat');

You can use slug or category ID too for the first parameter.

Upvotes: 1

Related Questions