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?
Hello,
Thank you for this modification! I finally had time to test this code in Code Snippet. Unfortunately, it doesn’t seem to work for me… I’m sorry, I’m really not proficient in PHP and I usually manage to figure things out on my own… but not this time! 😀
Could you please take another look? Here is the modified 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(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;
}
}
I didn’t change the ID of $search_id because I’m testing it with the first search instance I created, and I only modified the list of media IDs. I don’t see what could be wrong…
I cleared all caches to make sure, but nothing seems to work.
I created the code in Code Snippet as PHP code, allowing it to be active everywhere on the site…
Thank you for assisting me!
Have a nice day ! 🙂