[wp-hackers] Filter search query before execution

scribu scribu at gmail.com
Wed Sep 15 20:22:08 UTC 2010

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

function my_posts_search( $sql ) {
  var_dump( $sql );
  return $sql;

add_filter( 'posts_search', 'my_posts_search' );


More information about the wp-hackers mailing list