Home › Forums › General Issues › Search post by title of related post with relationship_field
I have post type Text and post type Author. Author could be connected to Text, but this type of post (Author) exclude from search since I need only Texts in search results.
How I can make Text searchable by title of Author connected to it?
If you are talking about the standard WP search, then you cannot search based on the value associated with another post.
What alternatives could be for standard WP search but the google?
WP search, will search the title and content of a post (ie, post_title and post_content). As I said, it is impossible to search content of other posts.
Not even paid plugins and services will search “related content”. The question is asked here a lot and there isn’t any CMS that exists where this can be done.
Here are some alternatives:
Using WP search it is possible to search custom fields of the same post by altering the WP query to look in these field. Plugins like https://wordpress.org/plugins/search-everything/ do this. But this means that you need the title of the related post in a custom field. This would mean that when saving the post (acf/save_post) you’d need to look at the relationship field and copy the title.
Alternately, you could get the title of the related post when saved (acf/save_post) and put this into a hidden DIV in post_content. But this would get complicated because every time you’d first need to look at the content and delete whatever might be in the hidden DIV before updating it.
You could build a custom search that has a select field to select filters to search by, for example to search for posts by an author that contains some content. This would be more complicated, but if you do a search you’ll find examples of this and even some tutorials for how to do it.
If you want to search for what appears on the page on the front of the site without doing any work then you’re only choice is to use an app like google or some other 3rd party search tool that is meant for doing this type of search.
Thank you for such a detailed response. I will read about that opportunities.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.