I have a scenario where i want to get featured property first then other properties which are not featured. I have saved a meta_key with _property_featured with 1 if the property is featured. For this i'm using pre_get_posts hook, here is the code
function my_property_modify_query( $query ) {
if ( is_post_type_archive('property') || is_tax('property_contracts')) {
set_query_var( 'orderby', 'meta_value_num' );
set_query_var( 'meta_key', '_property_featured' );
set_query_var( 'ORDER', 'DESC' );
}
}
add_action( "pre_get_posts", "my_property_modify_query" );
but it only shows featured property any suggestion why is he doing this ?