I have a custom searchbox that only searches a particular custom post type. On the results page I have modified seacrh.php to display the results slightly differently.

Mainly the title is different.

<?php 
        if ( 'wpdmpro' == get_post_type() ) : ?>                
            <h1 class="title">Documents Search</h1>             
        <?php 
        else : ?>
            <h1 class="title">Search</h1>
        <?php endif ?>

This works when there are some rsults, but fails on no results and displays the default title?

Why is the confitional failing. the url of the results page shows that the post type is still relevant?

http://siteurl.com/?s=searchterm&post_type=wpdmpro

Any idea?

Read more here:: Ignores post_type when no results


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: