Reply To: Fill select box from database


Ernest Marcinko

Hi Barbara,

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

$values = apply_filters("asp_cf_{filter_type}_values", $values, $item);

So for radio type, it's like this:

$values = apply_filters("asp_cf_radio_values", $values, $item);

for drop-down like this:

$values = apply_filters("asp_cf_dropdown_values", $values, $item);

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

$values = array(
    array('option1', 'Label value1'),
    array('option2', 'Label value2**'), // Double star at the label means, it is selected

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!

Ernest Marcinko

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