S
S
Sergey Sobol2020-10-30 19:50:33
WordPress
Sergey Sobol, 2020-10-30 19:50:33

How to add categories from woocommerce to your page?

Hello, there is a made-up store, and there you need to add categories, with certain styles. I created categories in woocommerce, and now I'm faced with the fact that I don't understand how to add them to the store. Using what? Can you please tell me how to add these categories exactly to the page that I need and how to style them later?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Zolin, 2020-10-30
@Dikkkey

You can use the function to get product categories get_terms(). To display a list of categories, you can use the example or customize it:

$terms = get_terms( 'product_cat' );

if( $terms && !is_wp_error($terms) ){
  echo '<ul>';
  foreach( $terms as $term ){
    echo '<li><a href="' . get_term_link( $term ) . '">' . $term->name . '</a></li>';
  }
  echo '</ul>';
}

And on the kama there is an excellent article with a bunch of examples

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question