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?

#44382
Ernest MarcinkoErnest Marcinko
Keymaster

Sure!

Can you try this variation maybe:

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

This one has the global database variable request so if that was the issue, then this may change something.