[wp-hackers] search_query in a plugin

Chip Bennett chip at chipbennett.net
Fri Oct 8 19:48:11 UTC 2010


I'd start here:

http://wordpress.org/support/forum/plugins-and-hacks

<http://wordpress.org/support/forum/plugins-and-hacks>Chip

On Fri, Oct 8, 2010 at 2:42 PM, Dhanushka Samarakoon <dhanu80 at gmail.com>wrote:

> Also looks like I'm in the wrong mailing list. Thanks for pointing it out.
> I looked here (http://codex.wordpress.org/Mailing_Lists) But seems like
> there's no support mailing list. Could someone point me in the right
> direction?
> Thanks.
>
> On Fri, Oct 8, 2010 at 11:27 AM, scribu <mail at scribu.net> wrote:
>
> > On Fri, Oct 8, 2010 at 7:02 PM, Dhanushka Samarakoon <dhanu80 at gmail.com
> > >wrote:
> >
> > > Hi,
> > > The following piece of code works inside a template file.
> > >    <?php
> > >         $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
> > > changes
> > > I should make to get that piece of code work inside a plugin?
> > > Thanks.
> > >
> >
> > This is really more of a support question.
> >
> > Add this line to wp-config.php and you should see an error message:
> >
> > define('WP_DEBUG', true);
> >
> > Also, that code is equivalent to:
> >
> > $search_posts = get_posts( 's=computer' );
> > echo count($search_posts);
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list