By default, the WordPress search engine only searches the titles and content of the posts. In order to include the category of the post in the search, the two following code snippets should be added in the
functions.php file in theme folder. The first of them creates a class that implements the methods responsible for searching by taxonomy. The second fragment creates a class object for the category.
If you do not use the child theme, remember that changes made to the
functions.php file will be overwritten when the theme is updated.
While copying code to
functions.php file it is not nessesary to copy
<?php opening tag.