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

Reply To: Display posts based on custom field

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

#41165
Ernest MarcinkoErnest Marcinko
Keymaster

Sure, it is possible by adding an additional argument and a tiny modification:

add_filter('asp_results', 'asp_remove_where_no_title_field', 10, 2);
function asp_remove_where_no_title_field($results, $search_id) {
	if ( $search_id == 1 ) {
		foreach($results as $k=>&$r){
			if ( get_post_meta($r->id, 'title_field', true) == '' ) {
				unset($results[$k]);
			}
		}
	}
        return $results;
}

On line if ( $search_id == ...) change the number to the search ID you want to apply the code to.