Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I use custom fields for lots of my content on both Posts and Pages, so that half of the text will be in the main post body and the other half in a custom field.

Unfortunately, when doing this only the text in the post body is searchable.

I want to have all the custom fields included in the search (just joined together as one). Preferably without installing a plugin, as all the plugins I have seen do not seem to be able to do this or they add loads of options I don't need.

I just would like one search box, that uses WordPress's default search but finds words in custom fields as well as those in the main body.

Is this possible?

share|improve this question
    
I can tell you that it's certainly possible, though I can't give you the specific code to make it happen. Hopefully someone else can chime in with more. I think you would hook in somewhere before the posts are selected, and check if it's a search. If so, filter posts_join and posts_where to join the post meta table and look for the search term in post meta. –  Milo May 31 '11 at 18:02
add comment

2 Answers

You could use a plugin like "Search Everything" which lets you toggle what to include in the search (including Custom Fields). Check it out here: http://wordpress.org/extend/plugins/search-everything/

share|improve this answer
    
Thanks, I am going to use this plugin. –  Shaun Jun 2 '11 at 7:30
    
this plugin have some flaws! Like showing you not published entries. If you use attachment search, ti will show attachments of not published posts..and so on. –  Tommixoft May 20 '12 at 9:50
add comment
up vote 0 down vote accepted

In the end I used the Relevanssi plugin which lets you include custom fields in the search quite easily, you can either include all the fields or choose which fields to include.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.