Until now I have been using below code to get the number of results when someone searches and to display that count.
<?php /* Search Count */ $allsearch =& new WP_Query("s=$s&showposts=-1"); $count = $allsearch->post_count; echo $count . ' '; wp_reset_query(); ?>
But this does not seem like valid code. It shows below error:
Deprecated: Assigning the return value of new by reference is deprecated
Can anyone please suggest the proper way in which I get get the search count. The above code is placed in the heading of my index.php file of theme within a conditional statement to display different heading based on what type of page a user is on.
allsearch = new WP_Query
without '&' to avoid deprecated notice.