I have a "one to many" relationship.
one forex-broker to many press-release.
the slug for the relationship: forex-broker-press-release
This is the content template of the forex-broker. If there is at least one press-release, it will show the header: Press Release.
I am using the following code:
[wpv-conditional if="( '[wpv-post-count item="@forex-broker-press-release.parent"]' gt '0' )"]
<h3>Press Release</h3>
[/wpv-conditional]
The problem is that, the Press Release header is not shown at all, whether the forex-broker has zero press-release or more than zero press-release.
What can I do to achieve what I want?
Hi,
Thank you for contacting us and I'd be happy to assist.
The "wpv-post-count" or "wpv-items-count" shortcodes return the count of results returned by a post view, which is why they can't be used in a content template directly.
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/ )
For what you're trying to achieve, the following condition will work:
[wpv-conditional if="( '[wpv-post-id item='@forex-broker-press-release.child']' ne '' )"]
<h3>Press Release</h3>
[/wpv-conditional]
You can learn more about the "item" attribute's usage, from this guide:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
My issue is resolved now. Thank you!