Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Display posts based on custom field › Reply To: Display posts based on custom field
January 30, 2023 at 5:08 pm
#41154
Keymaster
Hi,
Unfortunately the only way of filtering this is programmatically, by removing results after the search is finished, by checking for the “title_field” existence.
Something like this:
add_filter('asp_results', 'asp_remove_where_no_title_field');
function asp_remove_where_no_title_field($results) {
foreach($results as $k=>&$r){
if ( get_post_meta($r->id, 'title_field', true) == '' ) {
unset($results[$k]);
}
}
return $results;
}