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

Reply To: Custom field in search settings to appear dynamically

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Custom field in search settings to appear dynamically Reply To: Custom field in search settings to appear dynamically

#28754
Southernstarz2023Southernstarz2023
Participant

Hello, thank you for the resources and the code. I just tried all of the options you gave me and it is not working. The filters are still pulling in custom fields from products that are out of stock.

This is the code I tried to implement, I added the custom field to the ‘custom field name’ but should I be doing something different? Thanks! (I also tried it with both methods from the first link you sent about showing in-stock products only and neither worked)

`add_filter(‘asp_pre_get_front_filters’, ‘asp_change_a_filter’, 10, 2);
function asp_change_a_filter($filters, $type) {
$field = ‘winery’;
$exclude = array(‘value1’, ‘value2’);

foreach ($filters as $k => $filter) {
if ( $filter->type() == ‘custom_field’ && $filter->data[‘field’] == $field ) {
$filter->remove($exclude);
}
}
return $filters;
}’