I am looking for help (thank you) to edit the Woocommerce php widget for 'featured products'.
The file I think I need to edit is found:
wp-content/plugins/woocommerce/classes/widgets/class-wc-widget-featured-products.php
The problem: 1. Featured products currently display featured products from ALL categories.
The edit required: 1. To only display featured products within the current category being viewed.
So here is an example:
I have three categories (dog food, cat food, other stuff).
Each category has a category homepage:
www.mysite.com/other-stuff
When I add a featured products to the 'dog-food' category, the featured product widget also includes featured cat-food products. Which is useless if the customer does not have a cat.
I would like featured products widget to display only products that are featured from the current category being viewed - So dog-food customers will only see dog-food featured products (not cat-food or other-things)
I (think) I need to add an arguement to the PHP file noted above. Here is the current code found within the file:
$query_args['meta_query'][] = array(
'key' => '_featured',
'value' => 'yes'
);
I have tried adding:
$query_args['meta_query'][] = array(
'key' => '_featured',
'value' => 'yes',
'product_cat' => 'current_category'
);
But this did not work.
Any help anyone could offer would be much appreciated.
Many thanks in advance.
Use this wordpress plugin
https://wordpress.org/plugins/sp-woocommerce-featured-product-by-category/
In this plugin we have just changes the Featured product shortcode.
The default short code is : [featured_products per_page="12" columns="4"]
And change in this shortcode with the help of Featured product by categor plugin is : [featured_product_categories cats="CATEGORY_ID" per_cat="6" columns="3"]