Support

Account

Home Forums General Issues Search post by title of related post with relationship_field

Solving

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.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Search post by title of related post with relationship_field’ is closed to new replies.