Support

Account

Home Forums General Issues Query Multiple Conditions Reply To: Query Multiple Conditions

  • Awesome, thanks John! That worked. (Though a comma was needed after the ‘key’ line)

    The Toggle was actually a radio button with “Yes” and “No”, but I get it with true/false. The final query arg ended up being:

    function bem_query_only_published_posts( $args, $field, $post_id ) {
    
        $args['post_status'] = array( 'publish' );
    
        $args['meta_query'] = array(
    	  array(
    		  'key' => 'acf_toggle_field_123',
    		  'value' => 'Yes' 
    	  )
    	);
    
        return $args;
    }
    
    add_filter( 'acf/fields/post_object/query', 'bem_query_only_published_posts', 10, 3 );