WordPress – Show search term

Paste this in your search.php theme template or wherever you need it.

Results for <?php echo $_GET['s'] ?>

The $_GET['s'] is obviously the search term that was entered into the search box.

This will display the Search Term used that inspired the creation of the resulting page.

You may want to read these posts too!

« »


2 Responses to “ WordPress – Show search term ”

  1. Matt says:

    You should really sanitize that get variable before you include in your page like that…

  2. Jim Jim says:

    Yes, just a snippet. Obviously character, bad word filtering, length / format preferences need implemented based on what you desire to use the query for. That can be done several ways. I prefer referencing a flat file via a small PERL routine. One could dedicate a whole site just to sanitizing strings. Solutions and examples are always appreciated along with comments. That said, I will post a couple basic samples soon. I will address email format validations as well. Another big subject.

    It is always best to use a javascript validation before PERL or PHP routines. Then I like to re-validate strings that pass the javascript test through the server side routines. Almost double redundant but, does keep java enabled rejections from going through.

Leave a Reply