[wp-hackers] Including only excerpt in search

Rafael Ehlers rafaehlers at gmail.com
Wed Apr 20 10:06:24 UTC 2011


Nope, dont worked. I also examined the source code of relevance to see if I
can extract only that code, but not found anything near that.

Also I've previously read that link on codex that u send, nothing referring
to excerpt.

Thanks anyway!

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

> i've adapted this from the codex[1], i haven't tested it so let me know if
> it works.
>
> add_filter( 'posts_where', 'my_search_where' );
>
> function my_search_where( $where ) {
>    if ( is_search() ) {
>      $where = preg_replace(
>         "/\(\s*post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
>         "(post_title LIKE $1) OR (post_excerpt LIKE $1)", $where );
>    }
>
>    return $where;
>
> }
>
> you could also use the relevanssi plugin[2], which has an option for
> searching excerpts (as well as a whole bunch of other stuff that massively
> improves the search).
>
> cheers
> simon
>
> [1]
> http://codex.wordpress.org/Custom_Queries#Keyword_Search_in_Plugin_Table
> [2] http://wordpress.org/extend/plugins/relevanssi/
> _______________________________________________
> 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