Evaluate [related] fields
-
I have a custom post-type “containers”. Each container has an ACF relationship field called “acf_items” that can link to “item A” and/or “item B”.
Inside a specific container page, I want to display what item is contained in it (let’s say “item A”) but I also want to say what other items are available and not on display (in this case, “item B”).
Accordingly, I tried the following:
[loop type=containers] [if field=title value='Container of Choice'] [related acf_items] [-if field=title value='Item A'] This container only includes [field title]. [/-if] [-if field=title not value='Item A'] Other items not in this container are: [field title]. [/-if] [/related] [/if] [/loop]
The code produces no result, as if the related items are not being evaluated one by one against
value
.I also tried to work around it by using vars:
[loop type=containers] [if field=title value='Container of Choice'] [related acf_items] [set item][field title][/set] [pass vars] [-if var=item value='Item A'] This container only includes {-ITEM}. [/-if] [-if var=item not value='Item A'] Other items not in this container are: {-ITEM}. [/-if] [/pass] [/related] [/if] [/loop]
This, too, produces the same effect: nothing gets displayed. Yet, the
[related]
routine correctly outputs two separate values: “item A” and “item B”.It’s the
[if]
that doesn’t seem to do either comparison.Thanks for your help
- The topic ‘Evaluate [related] fields’ is closed to new replies.