Reply To: Checklist Field Displays as Array

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Checklist Field Displays as Array Reply To: Checklist Field Displays as Array

#5690

Ernest Marcinko
Keymaster

Nice. First of all you need to change back the Advanced description field option to the default {descriptionfield} because we are doing a different solution.

Then, I put together a filter, which parses through each result and gets the 'my_checkbox_list' field as per suggested on ACF support forums. Then it's appended to the description:

add_filter( 'asp_results', 'asp_checkbox_to_results', 1, 1 );
 
asp_checkbox_to_results( $results ) {
  foreach ($results as $k=>$v) {
    // Get the field
    $checkboxes = get_field('my_checkbox_list');
    // Append if exists
    if( $checkboxes ){   
        $checkbox_string = implode(', ', $checkboxes);
        $results[$k]->content  .= " – " . $checkbox_string;
    }
  }
 
  return $results;
}

Hopefully it will work.

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)