Skip Navigation

[Resolved] conditional – comments number – not working

This thread is resolved. Here is a description of the problem and solution.

Problem:

Show a different image if there are comments/no comments

Solution:

You can try shortcode [wpv-post-comments-number] like this:

https://toolset.com/forums/topic/conditional-comments-number-not-working/#post-1249021

Relevant Documentation:

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-comments-number

This support ticket is created 5 years, 7 months ago. 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.

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/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by Ido Angel 5 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#1248989

hey,
in trying to show a different image if there are comments/no comments, i've placed this in the post view:

[wpv-conditional if="( '[wpv-post-comments-number]' gt '0' )"]<img src="<em><u>hidden link</u></em>">[/wpv-conditional]

but it doesn't work - no matter how many comments there are, i still get the same image.
any ideas?
thx!

#1249021

Hello,

The shortcode [wpv-post-comments-number] will output:
No Comments
1 Comment
...

You can modify the shortcodes as below, and test again:

[wpv-conditional if="( '[wpv-post-comments-number none="0"]' gt '0' )"]<img src="<em><u>hidden link</u></em>">[/wpv-conditional]

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-comments-number
none:
' Text if there are no comments

#1249057

Thanks!
Actually it should be:

[wpv-conditional if="( '[wpv-post-comments-number none="0"]' eq '1' )"]<img src="<em><u>hidden link</u></em>">[/wpv-conditional]

since the value after "eq" is a value, not a number...
works!
thx