Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › How to Max Length CustomField result to 100 › Reply To: How to Max Length CustomField result to 100
December 1, 2020 at 10:52 am
#30444
Keymaster
Actually, I think so, maybe this variation:
add_filter('asp_cpt_advanced_field_value', 'change_asp_cpt_advanced_field_value', 10, 2);
function change_asp_cpt_advanced_field_value($value, $field_name) {
// Each line 'field_name' => length
$fields_length = array(
'custom_field_2' => 100,
'custom_field_3' => 200
);
if ( isset($fields_length[$field_name]) ) {
return wd_substr_at_word($value, $fields_length[$field_name]);
} else {
return $value;
}
}