I’m creating a menu bar that lists all of the posts titles and I want the ACF Relationship field to act as a subpage field on some of the posts. If a relationship field is set on a certain post, it will show up under which post it’s set (will look like a child) and it will exclude it on the main list (kind of like the parent list).
Sample expected output:
Black
– Avocado
– Beans
Blue
Green
– Broccoli
– Spinach
Yellow
Current output where the supposed sub posts is duplicated on the parent list:
Avocado
Beans
Broccoli
Black
– Avocado
– Beans
Blue
Green
– Broccoli
– Spinach
Yellow
Spinach
This is my code. I was trying to put all of the IDs that has a relationship field set so that when I test it on in_array, it will exclude it. The problem is that the $rel = get_field(“relationship”) only sets on posts that I call the parent posts and not the child posts so I can’t exclude them.