Skip Navigation

[Gelöst] Conditional Display For One-Many Relationship in Content Template

This support ticket is created vor 3 Jahre, 10 Monate. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 Antworten, has 2 Stimmen.

Last updated by Engedi vor 3 Jahre, 10 Monate.

Assisted by: Waqar.

Author
Artikel
#1667261

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?

#1667859

Waqar
Supporter

Languages: Englisch (English )

Timezone: Asia/Karachi (GMT+05:00)

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

#1668127

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.