Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 2 down vote accepted

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

<?php
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:

<?php
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
1  
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
add comment

Your Answer

 
discard

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.