Você está visualizando atualmente WooCommerce: Filter By Featured @ Products Admin

WooCommerce: Filter By Featured @ Products Admin

  • Autor do post:
  • Categoria do post:Woocommerce
  • Tempo de leitura:4 minutos de leitura

[]Unfortunately, if you still use the “star icon” to feature your WooCommerce products in the admin dashboard, there is no way to “sort by featured” or “filter by featured” in the Products table. If you’ve featured many products, it’s basically impossible to see them all at once, unless you scroll through many pages of products.

[]Today, we will study how to add a new filter beside the existing ones (“Select a category“, “Filter by product type“, “Filter by stock status“) so that you are able to see all your WooCommerce featured products or – in alternative – all products that are not featured.

[]In the snippet below, we first add a new select dropdown with the two options, and then we modify the query so that it can listen to the custom GET parameter, and return all featured products or all non-featured products. Enjoy!

Here’s the new dropdown filter under “Products” in the WordPress dashboard. You will be able to select “Featured Only” or “Not Featured”, and on “filter” button click, you will see the relevant results.

PHP Snippet: Add New Filter (“Filter by featured status”) @ WooCommerce Products Admin Table

/** * @snippet Filter by Featured @ WooCommerce Products Admin * @how-to Get CustomizeWoo.com FREE * @author Rodolfo Melogli * @compatible WooCommerce 8 * @donate $9 https://businessbloomer.com/bloomer-armada/ */ add_filter( ‘woocommerce_products_admin_list_table_filters’, ‘bbloomer_featured_filter’ ); function bbloomer_featured_filter( $filters ) { $filters[‘featured_choice’] = ‘bbloomer_filter_by_featured’; return $filters; } function bbloomer_filter_by_featured() { $current_featured_choice = isset( $_REQUEST[‘featured_choice’] ) ? wc_clean( wp_unslash( $_REQUEST[‘featured_choice’] ) ) : false; $output = ‘