Woocommerce orderby does not work with ajax pagination

Question

Am doing a custom page that looks like the shop page in Woocommerce, it’s all good so far, only one thing, the sort by functionality is not working since i also have an ajax scroll functionality when i sort the products list first time it’s good, but then when i scroll it gets me products that do not respect the sort, it’s like the orderby rule is only applied for the number of products am querying each time, here’s some code to consider

$args = array(
    'post_type' => 'product',
    'posts_per_page' => 12,
    'order' => 'asc',
    'orderby' => 'meta_value_num',
    'meta_key' => '_price'
);
$loop = new WP_Query($args);
...

Any ideas will be helpful, Thank you

0
ayoubelmoudni 4 weeks 0 Answers 0 views 0

Leave an answer