Support » Fixing WordPress » search results variable
12 years, 5 months ago
is there a variable that can be called to display the number of results in a search?
11 years, 10 months ago
just want to check whether anyone has any idea whether this can be done?
ie. to show the number of results from search.
I haven’t found anything yet, however I stopped looking awhile ago.
11 years, 8 months ago
I’m wondering the same thing. Show the number of search results, just like it shows the number of posts by a category-name. How to do this?
Edit: realised the code posted was incorrect.
11 years, 5 months ago
This code (taken & modified out of a plugin) should do what you want.
preg_match('#FROM (.*) GROUP BY#', $request, $matches);
$fromwhere = $matches;
$numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
if (0 < $numposts) $numposts = number_format($numposts);
<?php printf(__('Your search found %1$s matching posts'), $numposts, 'edit.php'); ?>
The complete plugin may be viewed here: