Search errors and "We couldn't find anything" message (2 posts)

  1. kjarrett
    Posted 9 years ago #

    I've noticed the support site works the same way my blogs do, when someone searches for something and no hits are found, the system spews a nasty looking error message and some brief explanatory text.

    Any way to change that, clean it up a bit? Looks like the system is crashing but in fact I think it's operating as designed.



  2. jaredquinn
    Posted 9 years ago #

    Take a look at search.php in your template...

    You should have something like:

    <?php if (have_posts()) : ?>

    ... code to display results ...

    <?php else : ?>

    ... code to show error ...

    <?php endif; ?>

    have_posts returns true on searches if there are results. So the code in the first ...'s will be the code to display the results, the code in the second ...'s will be the code to display a "not found".

    Mine does this for not found:

    <?php else : ?>

    <h5 class="center">No Matching Pages or Posts</h2>
    <?php include (TEMPLATEPATH . '/searchform.php'); ?>

    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.