Skip to content

Instantly share code, notes, and snippets.

@aimahdi
Created February 26, 2026 06:03
Show Gist options
  • Select an option

  • Save aimahdi/6204b571bab33f157e0ed3b032d3a4a2 to your computer and use it in GitHub Desktop.

Select an option

Save aimahdi/6204b571bab33f157e0ed3b032d3a4a2 to your computer and use it in GitHub Desktop.
<?php
add_filter('fluent_cart/shop_query', function($query, $params) {
// Change default sort to ID-based (instead of alphabetical)
// Only apply when sort_by is not explicitly set
if (!isset($params['filters']['sort_by'])) {
$query->orderBy('ID', 'DESC');
}
return $query;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment