All of my posts have an ACF Relationship field which allows admins to select any number of FAQs, which are a custom post type,
faq. On the frontend, these FAQs are displayed after the post's content, so I want my search results to include a post if the FAQ content matches the search query.
So, when an admin selects "FAQ 1" in the ACF Relationship field for "Post 1", and "FAQ 1" contains the word "foo", then a site search for "foo" using the native search feature should display "Post 1" as a result.
Currently, I setup
publish_faq to run several loops so that when a post or FAQ is being saved WP will output the linked FAQ content to a new key in the corresponding post's meta data, which then gets included in the native search via the hooks here: https://adambalee.com/search-wordpress-by-custom-fields-without-a-plugin
However, this seems a bit hacky and I was hoping someone with a better handle on SQL syntax may be able to help with a cleaner way to do this, possibly with some smart