Custom Empty Results page for my Custom Post Type
The problem is that when there are no posts in the search query, WordPress doesn’t set the post type in the global WP_Query (get_post_type() relies on that). So, when there are no search results, get_post_type() will return false and all of your custom template logic will be skipped. What you can do is also consider … Read more