I have a CPT "Web Properties" and a Post Type "Feed Source" created by WP RSS Aggregator.
I have a 1-1 relationship: 'Web Properties' - 'Feed Sources'
In the context of a specific Web Property, I want to check whether it has a Feed Source related to it.
I can find no documentation nor any support ticket about this.
I tried this:
[wpv-conditional if="( '[wpv-post-slug].item(@web-property-feed-source.child)' ne '' )"]
.......
[/wpv-conditional]
without success.
Do I need to write a shortcode?
Alex
Using ShortCodes you could use the Conditional / If button in any text editor to add the condition.
Since you simply want to check if a given post (current) has any related posts, you can check on the "related" Post ID with "if is empty/not empty)
This will produce something like:
[wpv-conditional if="( '[wpv-post-id item="@your-relationship.parent"]' eq '' )"]This post has no related post[/wpv-conditional]
Above would display "This post has no related post" when the post ha no related post, and nothing if there is a related post.
By changing the "eq" to "ne" you can invert the condition and output things when there are related posts, and nothing if not.
Using a Conditional Block instead, you can do the same but you'd never need to edit ShortCodes.
(I've added a screenshot of that setting)
Thanks Beda - I've got it working now.
Originally, I used
'[wpv-post-slug].item(@web-property-feed-source.child)'
(see above) which DID NOT work, but
'[wpv-post-slug item="@web-property-feed-source.child"]'
DOES work
I found the [---].item .... syntax somewhere on the forum. It appears that it is not equivalent to the [---- item=....] syntax.
Are there any circumstances where it's correct to use the [---].item.... syntax?
Alex
Yes, the first syntax you share is simply not valid: it seems manually constructed.
There is no such syntax as you use in the first example because there the ShortCode closes already before the actual attribute:
It cannot work like that by definition of a ShortCode
The syntax produced by the GUI is the right one to use.
My issue is resolved now. Thank you!