Support

Account

Home Forums General Issues How to get relationship in opposite direction

Solved

How to get relationship in opposite direction

  • I have two custom post types one is called “polls” and one is called “products.” On the polls post type I have a relationship field where I can select products from the products post type to be associated with the poll. On the poll page I am able to loop over the products and display all the products that are associated with that poll just fine, but I am wondering how I would go about getting this relationship in the opposite direction. For example, if someone goes to an individual product post, I would like to display which poll(s) that product is associated with. Can anyone point me in the direction of how I would accomplish this?

    Thanks!

  • You have 2 choices, you can do a reverse relationship query https://www.advancedcustomfields.com/resources/querying-relationship-fields/

    or you can install one of the available plugins that allow creating bidirectional relationships.

  • Excellent, thank you!

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

You must be logged in to reply to this topic.