Support

Account

Home Forums General Issues Query custom post based on user selections Reply To: Query custom post based on user selections

  • Checkboxes are a bit more difficult to search because the values are stored as serialized arrays. The query would look something like

    
    $args = array(
      'post_type' => 'salesperson',
      'meta_query' => array(
        'relation' => 'AND',
        array(
          'key' => 'country',
          'value' => '"'.$country.'"',
          'compare' = 'LIKE'
        ),
        array(
          'key' => 'state',
          'value' => '"'.$state.'"',
          'compare' = 'LIKE'
        ),
        array(
          'key' => 'industry',
          'value' => '"'.$industry.'"',
          'compare' = 'LIKE'
        )
      )
    );
    $query = new WP Query($args);
    

    there is more information here http://www.advancedcustomfields.com/resources/checkbox/