Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Select custom fields › Reply To: Select custom fields
February 10, 2025 at 10:51 am
#52883
Keymaster
Hi,
This could be possible via a bit of custom code and using a post meta filter, it’s not possible only via configuration.
1. Make sure to use the regular engine
2. Create a custom field filter exactly like this.
3. Make it visible by default
4. Try adding this code via the Code Snippets plugin or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.
add_filter('asp_query_args', function ( $args, $search_id, $options ) {
foreach ( $args['post_meta_filter'] as $key => $field ) {
if ( $field['key'] ==='dummy_field' ) {
$args['post_custom_fields_all'] = false;
$args['post_custom_fields'][] = esc_sql($field['value']);
unset($args['post_meta_filter'][$key]);
}
}
return $args;
}, 10, 3);
This will convert the filter into a search field instead.