WordPress search count results

You want to create a search page in WordPress where you count the results and show them on your page, for example: Searching for “apple” gives 3 results.

For getting this search counting you need to add the following code in your search file where you want to show this “counting sentence”.

First we make these variables:

$allsearch = &new WP_Query("s=$s&showposts=-1");
$key = wp_specialchars($s, 1);
$count = $allsearch->post_count;

Then we use $key for showing the search query and $count for how much results.

<p>Searching for "<?php echo $key;?>" gives <?php echo $count;?> results.</p>

Search and replace WordPress plugin

With search and replace plugin you can simply search in all your posts, posts from specific categories or specific pages and replace words. This is very helpful if you have many items in your database.