[wp-hackers] Including only excerpt in search

Rafael Ehlers rafaehlers at gmail.com
Wed Apr 20 07:57:50 UTC 2011


I have a custom post type that I only use the excerpt field, not the
content.

So I want WP to be able to search inside this excerpt field (post_excerpt in
DB)

I've tried several combinations with pre_get_posts filter but nothing yet!

function filter_search($query) {
    if ($query->is_search) {
$query->set('post_type', array('post', 'pages','produtos','artistas'));
 add_filter('the_content', 'excerpt');
    };
    return $query;
};
add_filter('pre_get_posts', 'filter_search');

function excerpt($content) {
$content = get_the_excerpt();
return $content;
}

Somebody help-me!


More information about the wp-hackers mailing list