Force out of stock products to be positioned at the end of the search query
-
I would like to ask if it is possible to force products which are out of stock to be positioned at the end of the search query.
Solutions I have tried:
StackOverflow
This one did work in the past, but has stopped workingI am currently also using the following code to limit search results to only display products:
add_filter('pre_get_posts','lw_search_filter_pages'); function lw_search_filter_pages($query) { // Frontend search only if ( ! is_admin() && $query->is_search() ) { $query->set('post_type', 'product'); $query->set( 'wc_query', 'product_query' ); } return $query; }
Thanks!
The page I need help with: [log in to see the link]
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Force out of stock products to be positioned at the end of the search query’ is closed to new replies.