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

Reply To: How to exclude certain media files from the search?

Home Forums Product Support Forums Ajax Search Pro for WordPress Support How to exclude certain media files from the search? Reply To: How to exclude certain media files from the search?

#43076
Ernest MarcinkoErnest Marcinko
Keymaster

You are welcome 🙂

No problem, that is also possible via this changed code:

add_filter("asp_query_args", "asp_query_args_change", 10, 2);
function asp_query_args_change($args, $search_id) {
	if ( $search_id == 1 ) {
		
		$include_ids = array(1, 2, 3); // Media file IDS to include
		
		// No change below
		$ids = implode(', ', $include_ids);
		$args['attachment_query']['where'] = "AND $wpdb->posts.ID IN($ids)";
		return $args;
	}
}

Just change the number on line with the ID of the search for which this code should be effective: if ( $search_id == 1 ) {