Hi @jomo5280,
When the filter runs, the sort order can be lost if the post widget settings don’t explicitly include it. The filter doesn’t preserve or reapply the sort order unless it’s explicitly provided.
To control the sort order when filtering, you have two options:
Use the Sorting Widget
If you use the sorting widget alongside the filter, it will automatically add the selected sort order into the filter query with no extra code needed.
Manually Enforce Sorting via a hook
It’s also possible to decide of the sorting order directly with a function:
add_filter('bpfwe_ajax_query_args', function( $args ) {
if ( is_page(123) ) {
$args['orderby'] = 'title';
$args['order'] = 'ASC';
}
return $args;
});
You would need to copy-paste the above code into your child theme’s functions.php file and replace the 123 by your page ID, so the sorting order would only be applied to the filter on that page.
Let me know if either works for you.
Regards,
Dara
Unfortunately I can’t use the sorting widget as I am using a post grid template.
I think I have the sorting resolved – however when a category is seleted, on load more/ infinite scroll it does not load more posts in the category, but rather seems to reset back to ALL and loads all categories – any ideas? thanks!
Hi @jomo5280,
Thanks for the heads-up. This issue was also reported by another user and has been fixed in version v1.4.1, so updating should resolve the problem with the pagination.
Also, just a quick note, the sorting widget should work across all widgets, whether it’s one from my plugin or Elementor Pro.
Let me know if you’re still seeing any issues after the update.
Regards,
Dara
Awesome! it works now!
thank you!
Glad to hear it’s working now, thanks for the update.
I’ll go ahead and close this topic for now. Let me know if there’s anything else.
Regards,
Dara