1

I have Photographer and Gear custom post types. I want to be able to relate multiple 'gear' posts under a 'photographer' and then also be able to point to the related 'photographers' under a gear page.

Here's an example diagram I created: enter image description here

3

WordPress by itself doesn't provide a built-in way to handle many-to-many relationships, you have two general ways of creating such relationship:

  1. Using a plugin

    The best plugin for this purpose is Posts 2 Posts by Scribu which is not maintained currently, but It's bug-less and won't introduce any problems in a long shot. But please be aware that this plugin requires some coding to get it up and ready and has to be active to work.

  2. Coding it yourself

    I'm not against the above plugin but, If you're not going to have only one relationship of this type then, I highly recommend you to develop a basic many-to-many relationship for it. The only reason for this is the age of plugin and its small community.

  • To suggest an outdated/unmaintained plugin is not a good idea in my opinion. ACF offers various relational fields and custom implementation isn't too difficult. Just save an array of gear_children in the Photographer's postmeta and an array of photographer_parent in the Gear's postmeta – kero Sep 3 '18 at 3:29
  • 1
    Yes, I'm completely against of using this plugin but, It's a quick workaround and by reading the ACF docs and forum they know this issue exists and they provided a workaround which consists of a data duplication. You can read more at: advancedcustomfields.com/resources/bidirectional-relationships – Farsad Sep 3 '18 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.