This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Fill select box from database

#11832
Ernest MarcinkoErnest Marcinko
Keymaster

Hi Barbara,

For custom field filters it is actually possible. For each value a filter is executed before output, in the following format:

[php]$values = apply_filters("asp_cf_{filter_type}_values", $values, $item);[/php]

So for radio type, it’s like this:

[php]$values = apply_filters("asp_cf_radio_values", $values, $item);[/php]

for drop-down like this:

[php]$values = apply_filters("asp_cf_dropdown_values", $values, $item);[/php]

In which the $values is an array of [option, value] keypais, like for example:

[php]$values = array(
array(‘option1’, ‘Label value1’),
array(‘option2’, ‘Label value2**’), // Double star at the label means, it is selected
etc…
);[/php]

Based on this you can make functions to fill or alter the values array as you like. For example, this function will add additional values to the output, for the filter on the ‘test_field’ custom field:

I hope this helps!