Hi folks,
I’m trying to extend the native WordPress search functionality to include values from an ACF taxonomy field.
Context: I’ve added a taxonomy field to media items so that I can assign tags to images. On the frontend, users can search for images. I use the standard WP_Query
object to find images and filter using the s
parameter. Nothing fancy. I understand this searches the post_title
and post_content
(the latter not super useful here).
I’d like to be able to add my tags
field to that search logic. I don’t think it’s possible to combine the s
value filtering with a meta_query
so probably need something bespoke. Have tried Relevanssi and Search Everything but those feels a little heavy-handed for this situation given I don’t want to hijack my main site search (which works fine natively). Likewise, it seems beyond the scope of ACF: Better Search because taxonomy field.
Hoping the collective powers of the ACF community might be able to point me in the right direction.
Cheers,
Andy
I’m not sure that this is for everyone, but I’ve been working on this idea for a while and I have my own plugin that inserts values from some fields into the post_content that allows the values to be searched with the standard WP search. I started with just text based fields and I have recently added some choice fields. My next step is to start adding relationship type fields with choices of what data from the related object that should be saved. You might want to take a look at what I’m doing and would be interested in any input over on github https://github.com/Hube2/acf-to-content
Thanks @hube2, shall give it a go.
I just added code for taxonomy fields, but it is untested. Let’s you copy name, slug, description. Haven’t had time to actually test it yet.