If you go to WordPress Dashboard > Products you will find default product admin filters such as “Select a category”, “Filter by product type”, “Filter by stock status”. What if you want to add more custom filters to let your shop managers find products easily?

For example, you could add “Filter by product tag” (“product tags” are one of the two default WooCommerce “taxonomies” together with “product categories”). Or, if you use custom taxonomies such as product brands, you could add a “Filter by product brand” dropdown.

Thankfully this is super easy – and here comes the proof 🙂

Adding custom admin product filters in WooCommerce

PHP Snippet: Add Custom Taxonomy Filter @ WooCommerce Products Admin Dashboard


/** 
 * @snippet       Show Custom Filter @ WooCommerce Products Admin
 * @how-to        Get CustomizeWoo.com FREE 
 * @sourcecode    https://businessbloomer.com/?p=78136
 * @author        Rodolfo Melogli 
 * @compatible    Woo 3.5.3
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */ 

add_filter( 'woocommerce_product_filters', 'bbloomer_filter_by_custom_taxonomy_dashboard_products' );

function bbloomer_filter_by_custom_taxonomy_dashboard_products( $output ) {
  
  global $wp_query;

  $output .= wc_product_dropdown_categories( array(
	'show_option_none' => 'Filter by product tag',
	'taxonomy' => 'product_tag',
	'name' => 'product_tag',
	'selected' => isset( $wp_query->query_vars['product_tag'] ) ? $wp_query->query_vars['product_tag'] : '',
  ) );
  
  return $output;
}

Share:

Leave a Reply