I am trying to: I have built a member database with member profile as parent post type (Expert) and additional member details as child post types (ie. Expertise, Education, etc...). On the "Find Experts" page, I've built a view with text search filter so visitors can search full expert profiles (parent and children included).
Link to a page where the issue can be seen: hidden link
I expected to see: What we would like to have happen is if the search term is found in either the parent post type (ew_expert) or in any of the child post types (ew_expertise, ew_education, etc...), then a brief of the parent post should be displayed.
Instead, I got: An example of where this does not work: expert Alan Abramson has an Education field filled in with Simon Fraser University. However, a search for the term "Simon" returns no results.
Hi, the text search field isn't designed to search for parent posts by child post terms. It's really a limitation of WordPress text search in general, which is not configured to search taxonomy terms at all (much less terms applied to descendent posts). A plugin like Relevanssi can extend text searches to include taxonomy terms, however it is not smart enough to know which parents should be associated with matching children. So the best approach is to copy any terms from child posts onto the parent post as well.
If I were trying to do something like this, I would create custom code with the cred_save_data hook or the save_post hook, depending on how those child posts are managed. I can show you some examples of this if you're comfortable writing PHP. Let me know which you need.
If you only have a few possible parent posts, it might be possible to manage this manually without the need for custom code - just apply any terms from the child posts to the parent post manually.
Once you have the terms applied to the parent posts, then you can configure Relevanssi to index taxonomy terms. Matching parents will begin to show up in the search results.
Hello, Christian, and thank you very much for taking the time to review my support request. Your explanation of the limitations is quite clear. However, I neglected to mention that the site I referred you to is merely a dev duplicate with only a few entries. The live site is in fact already populated with well over 600 parent posts, each with additional content in up to 19 child post types. I've read the documentation on cred_save_data and save_post and I don't think that will work out for me at this stage. However, I believe I can build a custom search page for the active theme which searches all post types and set up some conditionals to display the parent details of a child post if a search term is found in the child, employing the PHP approach to displaying parent posts. If you can think of any caveats I might run into, I welcome your input.
The main caveat I see there is you'll probably end up with duplicate parent results in that list. Consider if 3 child posts are found that have the term, and all 3 are children of the same parent. You'll end up with 3 links to the same parent post. Feel free to reopen this ticket if you'd like to discuss further.