Home Forums General Issues Differences between Bidirectional Relationship tutorial and ACF Post-2-Post


Differences between Bidirectional Relationship tutorial and ACF Post-2-Post

  • Hello,

    What are the functional differences between Bidirectional Relationships and ACF Post-2-Post?

    Thanks in advance!

  • The main difference is that using the tutorial provided by E

    1) you must supply the field key and name and create a new function for each field and supply the field name/key for each. My plugin finds the key automatically.
    2) It will only work if the same field group is used on different post types. In the plugin you just need to make sure the names of the fields are the same
    3) the code in the tutorial requires that you use the same field type, which should be implied by the fact that it’s the same field group. The plugin will let you mix post object and relationship fields.
    4) the code in the tutorial does not have any way to control overwrite settings should you run into a condition where the related posts has the max number of entries
    5) coding it yourself you could do more complicated fields where the plugin set some specific requirements for them, like not being in a repeater.

    Hope that helps

  • You made it very clear (and complete, I guess). Thank you again John!

  • I actually created that for my own use before the tutorial was available because I really dislike doing reverse relationship queries, really had nothing to do with making it easy to manage in the admin, that’s just a side effect. Almost everything I build has some type of relationship that needs to be displayed in both directions on the front end.

    I actually only released it recently to the WP repo because is requires ACF5. I guess that’s a difference I missed, the plugin won’t work in ACF4 but you can code your own functions that will. I also have an example of coding this yourself that takes a different approach here

  • John:
    I think that this is an awesome plugin and should definately be added to the core of ACF 5.

    I have suggested this before but nothing happened unfortunately :/

  • The reason that the functionality hasn’t been added to core is that, and this is just an educated guess, as as plugin created by a third party like myself, I can enforce some restrictions, like not supporting it for sub fields of repeaters, flex fields and clones, and requiring that the fields on all post types must have the same name.

    If added to the core it would not be long before all of the things I won’t support are requested and quite honestly, it would be nearly impossible to make it work under all conditions.

    The code that the developer has provided as an example as well as the alternate solution I created in my acf filters and function repo over on github, could be extended with effort to deal with specific fields under varying conditions.

    I actually respect Elliot’s decision to not add some things to the core of ACF and instead to provide more than adequate hooks so that we can extend it almost infinitely to meet the needs of specific projects.

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

The topic ‘Differences between Bidirectional Relationship tutorial and ACF Post-2-Post’ is closed to new replies.