Labels disappear when modifying query
-
Hi, I have the following code to modify the product order after filtering the archive page but the labels disappear when the products are filtered, any ideas how to fix that?
function custom_modify_main_query( $query ) { if ( ( defined('DOING_AJAX') && DOING_AJAX ) || ( $query->is_main_query() && is_post_type_archive( 'product' ) && ! is_admin() ) ) { $query->set( 'orderby', 'meta_value_num' ); $query->set( 'order', 'DESC' ); $query->set( 'meta_key', '_stock' ); } } add_action( 'pre_get_posts', 'custom_modify_main_query', 99);
- The topic ‘Labels disappear when modifying query’ is closed to new replies.