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.

        if ( 'wpdmpro' == get_post_type() ) : ?>                
            <h1 class="title">Documents Search</h1>             
        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?


Any idea?

Read more here:: Ignores post_type when no results


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: