WooCommerce Query Loop - Order By

Hi all,
Question; How do I get the Query Loop > Order by to use the WooCommerce ‘Sorting’? My client is complaining that since the site was switched over from Elementor he no longer has proper control over the display of his products (moving them around in WooCommerce Sorting Tab to how he likes it).


Bricks_woo-sorting-query-02

Suggestions please.

Thanks.

1 Like

Did you get this sorted?

Hi stevefrench, apologies for the delay in responding. No, I didn’t get it sorted in the normal sense, although since the updates it may be fine now. My Client decided to move away from that to use Best Sellers, Recommended Products and Popular Searches and a selection of selected Categories on the Home page (with all categories now laid out in a mega-menu).

use Query Loop – Bricks Academy
Query editor (PHP)

example for post

$order = $_GET['orderby'];

return [
'post_type' => 'post',
'orderby' => $order,

];

for sorting use link get parametr mysite/?orderby=title
OR widget Orderby

OR without widget, but widget code

<?php
$plink = get_page_link();
?>

<select onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);">
  
  <option value="">Select...</option>
  <option value="<?php echo $plink ?>?orderby=title">title</option>
  <option value="<?php echo $plink ?>?orderby=id">id</option>
  
</select>

You can try to set
Order by: Menu order and
Order: Ascending
like in the image.

What happens is when you are in “Sorting” first product in sorting list will be shown as first product on frontend.

i tried all the comments, none works for me =(