Show number of results on Wordpress search page

If you haven’t already read it, Michael Martin’s article on improving the wordpress search page is worth a quick glance. In return for a little fast and loose with global variables, we can improve performance while counting our search results. This works by foregoing a new WP_Query object in favor of simply hooking the existing global query:

<?php global $wp_query; echo $wp_query->post_count; ?> Results Found

I haven’t checked to see if WP_Query caches identical searches across instances, but this approach would at least save the overhead of instantiating a new query object.