Custom posts are not included in the search results by default. So, you need to create a function that allows them to be searched and queried.
Add below code in your child theme functions.php at the bottom.
add_filter( 'hcode_search_custom_post_types', 'hcode_search_custom_post_types_callback' ); if ( ! function_exists( 'hcode_search_custom_post_types_callback' ) ) { function hcode_search_custom_post_types_callback( $hcode_merge_posttypes ) { $hcode_append_posttypes = array( 'work' => esc_html__( 'Work', 'H-Code' ), ); $hcode_merge_posttypes = array_merge( $hcode_merge_posttypes, $hcode_append_posttypes ); return $hcode_merge_posttypes; } }
By putting this function, it simply filters search results by adding new arguments to the query results and it works for each custom post types.
To know more, follow this path:
Go to Admin Panel→ Appearance > Theme Settings > Layout Settings > Pages Layout Settings > Now navigate to ‘Search Content’ at the end of the currently opened tab. Here you can add the Work for the search result content.
So, from now onwards its quite easy to include custom post types in your search results!
NoteYou have to replace ‘Work’ with your custom post type.