Custom search: by post data and post metadata?

The built-in WP search looks only a Posts’/Pages’ Title and Content, not thru other elements like Custom Fields and the content of Shortcodes. There’s a number of plugs that will search Custom Fields:

http://wordpress.org/extend/plugins/wp-custom-fields-search/

http://wordpress.org/extend/plugins/search-everything/

http://wordpress.org/extend/plugins/relevanssi/

There also a filter apply_filters_ref_array() that “allows plugins to contextually add/remove/modify the search section of the database query.”

FYI, the search is defined in query.php, and looks like:

...if ( !empty($q['s']) )
...
($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')

So title and content are the only things in the default search.

Leave a Comment