Support

Account

Home Forums ACF PRO Call for posts on archive page if their relationship item is matching category Reply To: Call for posts on archive page if their relationship item is matching category

  • No, I have not seen anyone have success with making a bidirectional relationship field in a repeater work.

    In this case I would skip the bidirectional relationship and I would create a field for ingredients use only for making it easier to search. This field would just be a standard WP custom field with no need to be an ACF field that can be edited. It would not be editable from the ingredient side, only the recipe side. This would be a standard WP meta field that could hold multiple values.

    What I would do is I would create an acf/save_post action for recipes priority <10 so that it runs before ACF. I would loop through the repeater twice, once on the old values and once on the new values to collect a list of both old and new. Then compare and add/remove/update the meta key on for each ingredient.

    It would work very similar to a bidirectional field but instead getting the field to get the recipes on the ingredient side you would get the meta value and then use that value to query the recipes for each ingredient. Still not optimal, but better than a string of like queries.