WooCommerce Adding a Custom Filter to the Product Admin Area

In WordPress, you can go with Dashboard -> Products section. Here you can see default admin filter such as “Select a category”, “Filter by product type”, “Filter by stock status” but what you do if you want other custom filter which help your shop manager to find product easily.

For example, if you want to add “Filter by product tag” . “Product tag” is a default taxonomies of WooCommerce same as “Product categories”. If you want to add another filter than first create their custom texonomies. We will discuss above How To Create Custom Taxonomies in WordPress

So here we discuss WooCommerce Adding a custom filter to the Product Admin Area. Let’s have a look. Add below line of code in your theme’s functions.php file of your active child theme (or theme) and Save the file.

add_filter( 'woocommerce_product_filters', 'wdo_filter_by_custom_taxonomy_dashboard_products' );
 
function wdo_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;
}

Leave a Comment

Scroll to Top