WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can i display wath i am searching in a Search Theme.

Ex: I search for Keword : Battleship

Result :

Your results retrive (3 posts) with the subject Battleship.

share|improve this question
up vote 2 down vote accepted

Add the following code to your template's search.php - somewhere before the loop:

global $wp_query;
echo 'Your results retrive ('.$wp_query->found_posts.' posts) with the subject '.get_search_query().'.';

If search.php does not exists in your template's directory, either copy archive.php (if it does not exists too, copy index.php - see template hierarchy) and rename it to search.php or insert following code, again before the loop, right into archive.php or index.php respectively:

if ( is_search() ){
    global $wp_query;
    echo 'Your results retrive ('.$wp_query->found_posts.' posts) with the subject '.get_search_query().'.';
share|improve this answer
way the post get - ? – Batman Feb 5 '13 at 23:52
This answer was automatically flagged as low-quality probably because it is a block of code with no explanation, even if the solution works. If you could provide a description of what the code does it would make a better answer. – s_ha_dum Feb 5 '13 at 23:55
Sorry for that - I've improved the answer... – david.binda Feb 5 '13 at 23:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.