Amend taxonomy to search in wordpress admin

Welcome to the community 🙂

Generally speaking, the WP_Query is quite a central piece of everything in WordPress, so I’d recommend first getting a solid understanding of what is going on inside the core before tinkering too much with WP_Query as it will often have undesired side-effects which are hard to understand & debug.

Having that said, I see where you want to go and in a specific use-case your solution might do just fine.

I haven’t tested your code but it should work (well, at least affect the search) if you change this:

wpse342309_search_terms( $query, 'help_cat' );

to this:

$query = wpse342309_search_terms( $query, 'help_cat' );

Two more points:

  1. Are you aware that the solution will also affect search results in the frontend?

  2. Also, the solution doesn’t respect sort order, which means that no matter how the results are sorted, the terms will always come first, always in the same order.