Quick Tip 18 – WP Search Results

Another Quick Tip today that improves the search results on your blog. This little snippet of code will recall the search query and the amount of results.

The code below:

Quick Tip Gary

<h2>Search Result 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(’ &mdash; ‘); echo $count . ‘ ‘; _e(’articles’); wp_reset_query(); ?></h2>

Open up the search.php file in your theme and replace in the code of the H2 Search Results. Once you have done this and uploaded the file you will see the search query and amount of relevant posts.

Related posts:

  1. Quick Tip 15 – WP More Tag
  2. Quick Tip 12 – WP Gravatar
  3. Quick Tip 13 – WP Promotion
  4. Quick Tip 14 – WP E-commerce
  5. Quick Tip 19 – WP Permalinks

Tags: ,

Leave a Reply

Contact Us Today...

For more information regarding any of our services or to arrange a free consultation simply send us a message or call 02920 290 080 for Cardiff and 01179 000 482 for Bristol.

Firefox 4 Beta

Mozilla have released the first beta version of Firefox 4. The latest version of this browser will include better support for many of the new web technologies, a new add on manager, crash protection from third party plugins and accelerated hardware support. One of the most obvious changes is that the tabs have now been moved [...]
» more

Cardiff: 02920 290 080 Bristol: 01179 000 482