[wp-hackers] Filter search query before execution

Ryan Bilesky rbilesky at gmail.com
Wed Sep 15 22:12:30 UTC 2010


It doesn't look like that filter is what i need.  I want to capture the
search query before anything is done with it to change it, not while its
doing some queries to find results for the search.
On Wed, Sep 15, 2010 at 1:22 PM, scribu <scribu at gmail.com> wrote:

> On Wed, Sep 15, 2010 at 9:28 PM, Ryan Bilesky <rbilesky at gmail.com> wrote:
>
> > Best i can find this is a really new filter, only since 3.0 and I can't
> > seem
> > to figure out how to get it working.  I setup a simple example on my demo
> > install of WP.  I had my filter function return Hello World and searched
> > something else that didn't yield any results.  Hello world should give
> the
> > the initial hello world post, i get nothing.
> >
>
> You should look at what the filter expects first, before returning
> something
> else:
>
> function my_posts_search( $sql ) {
>  var_dump( $sql );
>  return $sql;
> }
>
> add_filter( 'posts_search', 'my_posts_search' );
>
>
> --
>  http://scribu.net
> _______________________________________________
> 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