Any idea how to modify this script i wrote below so it ONLY applies to woocommerce product pages?
/**
* Sort product search results by menu order
*/
add_action('pre_get_posts','sortby_menuorder_query');
function sortby_menuorder_query($query) {
if ( isset($_REQUEST['s']) ) {
$query->set('orderby', 'menu_order');
$query->set('order', 'ASC');
}
}
I thought it would help make it so the products would appear in the correct order based on Menu appearance set in the product backend, and it totally does. But then it also applies that same menu order logic to every single page, post, and CPT on the entire website. So it fixes my product search, and breaks my standard search.