I have a site using Advanced Custom Fields to create and store various bits of relevant info. These need to be included in the main general search, which by default only searches the title and main content.
I’ve found plenty of info about getting search results based on specific bits of postmeta, but I have an issue with that. There are a potentially unlimited amount of potential fields in postmeta to search.
The solution could either search anything in postmeta or anything with a meta_key that matches this regex: content_section_[0-9]{1,4}_content_.{2,8}
Example meta_keys to match are:
content_section_0_content_title
content_section_0_content_title
content_section_4_content_subtitle
content_section_8_content_text
Any way that I can alter the fields searched to include the postmeta would be very much appreciated.
If your up for using a plugin, Relevanssi – A Better Search might be worth trying out.
The standard (free) version supports searching post meta.