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

Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: How to exclude certain media files from the search? #44410
    Studio HiriloStudio Hirilo
    Participant

    Hello!
    I found the issue!!! πŸ˜€
    It turns out my search instance was using the index table engine… All I had to do was switch to the regular engine, and… miracle, the code worked!!!

    Thank you once again for your valuable assistance.
    I wish you all the best!
    Bye

    in reply to: How to exclude certain media files from the search? #44383
    Studio HiriloStudio Hirilo
    Participant

    Darn… it still doesn’t work… πŸ™

    in reply to: How to exclude certain media files from the search? #44380
    Studio HiriloStudio Hirilo
    Participant

    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 ! πŸ™‚

    in reply to: How to exclude certain media files from the search? #43075
    Studio HiriloStudio Hirilo
    Participant

    Hello !
    Thank you very much for your prompt response. I will try that with Code Snippet. I just have one thing I forgot to mention, oops: I will create multiple search instances, and each one should include different files IDs. How can I associate each specific code with the different instances? Thank you for your answers!
    See you soon.

Viewing 4 posts - 1 through 4 (of 4 total)