RSS
 

WordPress – Show search term

28 Apr

Put this is 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.

 
 

Leave a Reply

 
 
  1. Matt

    May 11, 2009 at 8:28 pm

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

     
  2. Jim

    Jim

    May 29, 2009 at 6:19 pm

    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.

     
 

Bad Behavior has blocked 124 access attempts in the last 7 days.