I'm trying to order product by regular price with the field _regular_price but it's not affecting the order.
There is also a custom filter on the left side which is also not working properly. The filter is set as the custom fields of the products with all OR relationships. Because multiple laptops (in example) can have 3GB of RAM and INTEL I3 as a processor. hidden link -> that's the archive, this is the name of that WordPress archive "Proizvodi, Kategorije, Oznake, Kategorije proizvoda, Proizvod oznake, Kategorije"
Well - The default shop page of Woocommerce plugin is archive page of post type "Products", and the query of WordPress archive page is setup by wordpress, Views cannot change it, but you can try with WordPress action hook "pre_get_posts":
So, I've added the following code at "Custom Code" section:
=> hidden link
function sort_by_regular_price($query) {
if ($query->is_post_type_archive('product') && $query->is_main_query()) {
$query->set('order', 'ASC');
$query->set('meta_key', '_regular_price');
$query->set('orderby', 'meta_value_num');
}
}
add_action('pre_get_posts', 'sort_by_regular_price');
But another issue is still present. Please, when you click on multiple filter choices, it doesn't show good. It only shows good when I have 1 filter checked.
When I choose more of them, it throws "No items found" (on my Croatian language of course). hidden link
I hope you understand what I'm trying to describe, if not, I'll make a video, no problem 🙂
Best,
Ivan
New threads created by Minesh and linked to this one are listed below: