Support

Account

Home Forums ACF PRO meta_query doesn't work for filter a query by an ACF value and order by another Reply To: meta_query doesn't work for filter a query by an ACF value and order by another

  • Hi, Noone responds but I try to use pre_get_posts:

    function my_pre_get_posts( $expo_query  ) {
    	
    	// do not modify queries in the admin
    	if( is_admin() ) {
    		
    		return $expo_query ;
    		
    	}
    	
    
    	// only modify queries for 'exposiciones' post type
    	if( isset($expo_query ->query_vars['post_type']) && $expo_query ->query_vars['post_type'] == 'exposiciones' ) {
    		
    		$expo_query ->set('meta_key', 'expo_start_date');	 
    		$expo_query ->set('orderby', 'meta_value');	
    		$expo_query ->set('order', 'DESC'); 
    		
    	}
    	
    
    	// return
    	return $expo_query ;
    
    }
    
    add_action('pre_get_posts', 'my_pre_get_posts');

    without success. 🙁