Sort WooCommerce products by price DESC

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php

// Add to your (child) theme’s functions.php
add_filter( ‘facetwp_is_main_query’, function( $is_main_query, $query ) {
if ( ‘product_query’ == $query->get( ‘wc_query’ ) ) {
$query->set( ‘orderby’, ‘price’ );
$query->set( ‘order’, ‘DESC’ );
}
return $is_main_query;
}, 10, 2 );

{{/gist}}