[wp-hackers] Including only excerpt in search
Simon Blackbourn
piemanek at gmail.com
Wed Apr 20 10:47:27 UTC 2011
> 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.
More information about the wp-hackers
mailing list