I
I
Ilya Derevyannykh2022-04-12 14:00:55
WordPress
Ilya Derevyannykh, 2022-04-12 14:00:55

How to display the categories of goods that are in this brand?

It does not allow you to put a link in another way, so
on host1839650.hostland.pro/category/filtry/?filter_brand=alessi you need to display all categories that include products with this brand. How to implement it?

Here host1839650.hostland.pro/category/filtry/ subcategories come out. But how can you also make them appear in the brand?

Output with this code

function woocommerce_product_category( $args = array() ) {
  $woocommerce_category_id = get_queried_object_id();
  $args = array(
    	'parent' => $woocommerce_category_id
  );
  $terms = get_terms( 'product_cat', $args );
  if ( $terms ) {
    	echo '<div class="my-category"><div><ul class="woocommerce-categories">';
    	foreach ( $terms as $term ) {
        	echo '<li class="woocommerce-product-category-page">';
      echo '<a href="' .  esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . '">';
            woocommerce_subcategory_thumbnail( $term );
      echo '</a>';
      echo '<p>';
        	echo '<a href="' .  esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . '">';
        	echo $term->name;
        	echo '</a>';
        	echo '</p>';
        	echo '</li>';
    	}
    	echo '</ul></div></div>';
  	}
}

add_action( 'woocommerce_before_main_content', 'woocommerce_product_category', 100 );


I tried brands in different ways, both as a category and as a filter. How can this be resolved?

The main task is to do this without doubling the tree

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question