wp query – Block internal search queries with pre_get_posts and regex rules


This relates to my previous question: Internal search spam (UPD: I no longer use Ivory Search)

The closest question I found: Block search keywords

As I understood, I need to use pre_get_posts, but I don’t exactly know where it should go (functions.php?) and how I can create a regex-based rule to exclude everything that has “www.” in it and non-Latin or non-numeric symbols like emojis and Cyrillic letters.

I have the results noindexed and blocked in robots.txt, but I’d like to fix the root of the problem if possible by stopping the queries from happening at all. Any help here would be greatly appreciated.

Terry 1 year 2021-12-10T06:32:29-05:00 0 Answers 0 views 0

Leave an answer