php – Error in suggestion in search area


I have a problem and I need help.

On my website I customized the search area. I let it display only the categories I chose using the category ID.


Let’s say I have 10 categories on the entire site but I only want 5.

function SearchFilter($query)
if( $query->is_search && ! is_admin() )
return $query;

When I click on the magnifying glass icon and without typing anything, the search results show the categories I determined.

However, if I click on the magnifying glass and type only 1 character, in the suggestions appears the category that is not part of the list I programmed. But if I click on search, that category doesn’t appear in the results.

The error is that this category appears in the suggestions and not on the results page.

Does anyone have any idea how to solve this problem or how to hide the category by ID in the search suggestions?

Anonymous 6 months 2021-06-03T16:01:11-05:00 0 Answers 0 views 0

Leave an answer