Add Custom Taxonomy Filter on Products Dashboard.

How To Filter Products by Taxonomies in the Dashboard?

 

WooCommerce provide Many Product filters on admin screen , such as “Select a category”, “Filter by product type”, “Filter by stock status”.

For example ,if you want to add Custom filters like “Filter by tags” etc on products admin screen.
“Product tag” is a default taxonomies of WooCommerce same as “Product categories”. We can use ‘woocommerce_product_filters’ filter for adding other texonomy filters too.

 

Paste this code to your theme’s functions.php for adding filter to product admin screen.

 

function CustomTaxonomyFilter( $data ) { 
  global $wp_query; 
  $data .= wc_product_dropdown_categories( array(
    'show_option_none' => 'Filter by Tags',
    'taxonomy' => 'product_tag',
    'name' => 'product_tag',
    'selected' => isset( $wp_query->query_vars['product_tag'] ) ? $wp_query->query_vars['product_tag'] : '',
  ) );
return $data;
}
add_filter('woocommerce_product_filters','CustomTaxonomyFilter' );

 

Same filter can be used for extra custum texomony added.

 

function CustomTaxonomyFilter( $data ) { 
  global $wp_query; 
  $data .= wc_product_dropdown_categories( array(
    'show_option_none' => 'Filter by Brands',
    'taxonomy' => 'product_brand',
    'name' => 'product_brand',
    'selected' => isset( $wp_query->query_vars['product_brand'] ) ? $wp_query->query_vars['product_brand'] : '',
  ) );
return $data;
}
add_filter('woocommerce_product_filters','CustomTaxonomyFilter' );

 

Related Blogs

How To Limit Search To Post Titles?

I added a text field to the posts filter form and I use s= parameter to make the search work. But how to search only in the title of the post (not in the content)? how to limit search to post titles? How to search only by Post Title?

Fetch WordPress Categories

Fetch wordpress categories Using inbuilt functions like get_categories(), wp_list_categories(), wp_dropdown_categories().

Request A Quote

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.