I am trying to: use one template with different parent/child post types. Child condition looks at parent field value. In child condition is used 2 different parent types with OR:
( empty( $(glavanastavnika).item(@miupeduch.parent)) OR empty( $(wpcf-glavanastavnika).item(@miuandmironline.parent)) )
I expected to see: content will be displayed depends from post type is used
Instead, I got: nothing is displayed. If remove one condition then content is displayed.
I'm trying to understand the context and exactly what you are trying to do, can we please clarify that.
I believe you have two parent:child relationships.
What post types are involved in the two relationships?
From your question I'm guessing that both relationships have the same child post type but different parent post types. Both parent post types have the same custom field.
You are using a content template for the child post type, and adding the conditional tests to that template, checking the values of the custom field of either parent.
I don't need access, I've set up something very similar on my own site, and I'm having trouble getting any combination or variation to work.
I'm out of time for today, so I'll resume looking into it in the morning.
One question, though, is whether it is feasible to use different combinations of conditions to achieve what you want.
You could, for example, have a condition to test if we are currently viewing a post of type Child 1, and then nest a condition to test the field value from Parent 1. Then another condition to test if we are currently viewing a post of type Child 2, and then nest a condition to test the field value from Parent 2.
Would something like that work? Combining conditions testing related content is proving very tricky.
What exactly were the conditions you tested? The same as before, or did you try splitting out the conditions and nesting them as I suggested in my previous reply?
Combining conditions with AND or OR is not the same as nesting separate conditions.
(Combing conditions which test data of related posts isn't working properly, and I will escalate that to the developers, but I'm trying to see whether there is a solution that can work for you now.)
No, I meant nesting conditional blocks (each with one condition), so you have a structure like in my screenshot.
So the outer block would test if the current post type is child-1 and then the inner condition—knowing that the current post is of type child-1—would test a condition relating to a parent of child-1.
You would have similar nested conditions where the outer block was checking if the current post type is child-2, etc.
I don't know if that logic works for you, but if so it will allow you to move forward with a single template assigned to both child post types (rather than having to create separate templates for each post type).
got it, unfortunately such approach means that I have to anyway double content for each block. While I would like to avoid it. Is there only way, right? no other solution?
I've found that I can put one template inside 2 conditional blocks. Construction will be more complicated but content will not be doubled. Thank you for this workaround!