Include custom post types in the search using WordPress hooks
To include custom post types in the default search, we need to modify the search function using an action hook. Post types that we want to search through are added to the search query in an array. The array needs to include WordPress’s default post & page types as this function does not append post types to the default search.
Paste the following code into your theme’s