How to create a message for a failed search

Forums › Forums › Search & Filter Pro › How to create a message for a failed search

Viewing 2 posts – 1 through 2 (of 2 total)
  • Anonymous
    #3027

    Hey Ross,

    Is there a way we can create a custom message when a search does not produce a result (say if the user picks too many categories that don’t match a result)? Right now it just shows a blank page.

    It would be great to have the site say something like “No results matched your search criteria. Please try again.”

    Thanks!
    -Charley

    Ross Moderator
    #3050

    Hey Charley

    In your template you can add something like:

    global $wp_query;
    $total_results = $wp_query->found_posts;
    if($total_results==0)
    {
        _e('Sorry, no posts matched your criteria.');
    }

    There are other examples in here:
    http://codex.wordpress.org/The_Loop

Viewing 2 posts – 1 through 2 (of 2 total)

Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.