[wp-hackers] Including only excerpt in search

Rafael Ehlers rafaehlers at gmail.com
Wed Apr 20 19:47:52 UTC 2011


Wow! Perfect, works like a charm!

Thanks Simon!!

On Wed, Apr 20, 2011 at 7:47 AM, Simon Blackbourn <piemanek at gmail.com>wrote:

> > Nope, dont worked.
>
>
> the regular expression was failing, this now works for me:
>
> add_filter( 'posts_where', 'my_search_where' );
>
> function my_search_where( $where ) {
>
>    if ( is_search() ) {
>    $where = preg_replace(
>     "/post_title\s+LIKE\s*(\'[^\']+\')/",
>     "post_title LIKE $1) OR (post_excerpt LIKE $1", $where );
>    }
>
>    return $where;
>
> }
>
>
>
> >
> > I also examined the source code of relevance to see if I
> > can extract only that code, but not found anything near that.
> >
> >
> relevanssi works on a very different basis: it generates a table of indexed
> terms which is updated when you save a post, and it then searches that
> table
> rather than searching the posts table.
> _______________________________________________
> 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