Home Forums General Issues Checkbox List Displaying as an Array in Search


Checkbox List Displaying as an Array in Search

  • I am using ACF for a custom field for a list, it is set up as a checkbox type.
    I want to display those fields in a search plugin called Ajax Search Pro –

    In the Advanced Description Field of the plugin I can set the custom field to display via a front end setting -my field for the checkbox is named my_checkbox_list and has 3 values – I call the custom field as below in the search plugin…

    {descriptionfield} – {my_checkbox_list}

    But when the search displays it shows just Array as below
    checkboxlist array

    I spoke to the author of Ajax Search Pro and he replied:

    I believe ACF runs a function through that array to display it, or uses some kind of code to parse through the array. It means that not the checkbox HTML is stored in the custom field, but some kind of array values, that are transformed into checkboxes.

    You can ask the ACF author how the checkbox array is transformed into actual HTML checkboxes, then I might be able to suggest a customization or filter function to append the transformed code to the result list. It’s probably going to be some kind of function or a small snippet from the ACF plugin code.

    How can I show the array’s content?

  • Hi @neilgee

    So you want to show the actual text from those checkbox selections? Not the checkboxes themselves?

  • Hi @jonathan yes the actual text from the selections, so only if selected in the backend.

  • Hi,

    Alright. We’ll the problem you have here is that you’re directly calling to the meta value with AJAX search pro and since you are able to select multiple values with the checkbox field those are saved as a serialized array in the DB.

    So instead of directly adding it to ajax search pro like you’re doing now you’d need to add it using a filter or something like the author says.

    Say he gives you an action hook with which you can add the info your function would probably look something like:

    function setup_my_checkboxes(){
    	$checkboxes = get_field('my_checkbox_list');
    	if( $checkboxes ){
    		$checkbox_string = implode(', ', $checkboxes);
    		echo ' – ' . $checkbox_string;
  • Thanks Johnathan, yes tested that and it outputs the list – now i’ll see if I can hook that in. Appreciated.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Checkbox List Displaying as an Array in Search’ is closed to new replies.