[wp-hackers] search_query in a plugin
mail at scribu.net
Fri Oct 8 16:27:08 UTC 2010
On Fri, Oct 8, 2010 at 7:02 PM, Dhanushka Samarakoon <dhanu80 at gmail.com>wrote:
> The following piece of code works inside a template file.
> $search_query = new WP_Query();
> $search_posts = $search_query->query('s=computer');
> echo sizeof($search_posts);
> But it doesn't work inside a plugins php file. Does anyone know what
> I should make to get that piece of code work inside a plugin?
This is really more of a support question.
Add this line to wp-config.php and you should see an error message:
Also, that code is equivalent to:
$search_posts = get_posts( 's=computer' );
More information about the wp-hackers