WooCommerce has a simple way to pick “Featured” products by clicking a little star icon in the “Featured” column in the admin area.
I need to be able to filter and show only featured products in the admin area. Does anyone know of a straightforward way to do this?
I did some digging and it turns out this is done with meta key/values, where _featured
is the key and the value is either yes
or no
.
Unfortunately, since it’s not done with taxonomies like product categories, there is no way to use the filter functionality in the admin area to show only featured products. You can sort the featured column so they are all either at the top of bottom of the product list, but that’s it.
You can sort your products list by the featured status. Just click on the star at the top of the column…. once will put all non-featured items at the top, and twice should reverse this and put all featured items at the top.
Your admin url will look like:
/wp-admin/edit.php?post_type=product&orderby=featured&order=desc
EDIT:
Ok, so it turned out to not be that hard to filter by featured status. WooCommerce is filtering by “subtype”, and since that is also filtering by meta, we can mostly just copy their code and make a few adjustments.
The first function adds the select/drop-down element, while the second handles the adjustments to the admin query.
Updated for WooCommerce 3.0
The
parse_query
callback must be updated as the featured status is no longer stored as post meta.I found this plugin: https://wordpress.stackexchange.com/a/45447/15190, which I was able to customize to provide a select list to filter by Featured product. With that, I am able to then use WooCommerce’s Sort Products drag and drop feature to easily change the order that Featured products appear in the Featured Products widget and other places.
Here is the code with my customizations that will make it work for WooCommerce Featured Products:
You can use WordPress plug-in Filter Featured Products for WooCommerce.