Display number of results in search page on WordPress

hoangvu

New member
Joined
Jun 6, 2012
Messages
1,835
Points
0
When a visitor made a search in wordpress it does not return the number of results found. Of course in many cases it is very useful one know how much the results are followed the way to achieve it.

Simply locate the file search.php and in this we are looking for the following line of code:

<h2> Search Results </ h2>

Replace it with the following code


Code:
<h2> Search Results for <? php  
  / * Search Count * /  
  $ Allsearch = & new WP_Query ("s = $ s & showposts = -1");  
  $ Key = wp_specialchars ($ s, 1);  
  $ Count = $ allsearch-> post_count; _e ('');  
  _e ('<span>');  
  echo $ key; _e ('</ span>'); _e ('-');  
  echo $ count.  ''; _e ('Articles');  

  wp_reset_query ();?> </ h2>
Hope it's helpful to you!
 

hoangvu

New member
Joined
Jun 6, 2012
Messages
1,835
Points
0
Thanks.
You can use it to count number of search results somewhere in your search page. it's useful for viewers.
 
Older threads
Replies
0
Views
2,006
Replies
5
Views
3,918
Replies
1
Views
5,080
Latest threads
Replies
1
Views
69
Replies
0
Views
131
Replies
0
Views
39
Replies
2
Views
588
Replies
4
Views
634
Recommended threads
Replies
18
Views
6,656
Replies
14
Views
5,867
Replies
6
Views
3,779

Latest postsNew threads

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top