Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonporter007/952b570b61582abc8b8be97d04b155cc to your computer and use it in GitHub Desktop.
Save simonporter007/952b570b61582abc8b8be97d04b155cc to your computer and use it in GitHub Desktop.
WooCommerce Extra Product Sorting Options: Adjust the query used with 'sale items first' to also show non sale items
<?php // only copy if required!
// Allows products with no sale price to display alongside sale items
function sv_posts_clauses( $args, $wp_query ) {
$args = str_replace("wp_postmeta.meta_key = '_sale_price'","wp_postmeta.meta_key IN ('_sale_price', '_virtual')", $args);
return $args;
}
add_filter( 'posts_clauses', 'sv_posts_clauses', 15, 2 );
@ssoulless
Copy link

Thanks, it is working fine, only sorting single products, but not variable products.

@simonporter007
Copy link
Author

Thanks for letting me know, that's great news! I'm afraid the plugin doesn't support variable product sorting at this time but thanks so much for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment