I have a view with the sole purpose of counting how many items are related to a post ID. To prevent the output from wrapping in a div that I can't seem to add a class to for formatting, I pass a param via the view shortcode to modify the output to only return the [wpv-found-count]. I call this view like:
The view does display the count number correctly. Now, when I try to use the output of that view in a conditional to determine if my output term is singular or plural I can't seem to get it to match. I've tried combinations of using and not using single quotes with no luck. I've tried the following but none of the conditionals end up matching:
[wpv-conditional if="( [wpv-view name="count-items-in-relationship" wpvrelatedto="[wpv-post-id]" version="short"] ne 0 )"]![/wpv-conditional]
[wpv-conditional if="( '[wpv-view name="count-items-in-relationship" wpvrelatedto="[wpv-post-id]" version="short"]' ne 0 )"]@[/wpv-conditional]
[wpv-conditional if="( [wpv-view name="count-items-in-relationship" wpvrelatedto="[wpv-post-id]" version="short"] ne '0' )"]#[/wpv-conditional]
[wpv-conditional if="( '[wpv-view name="count-items-in-relationship" wpvrelatedto="[wpv-post-id]" version="short"]' ne '0' )"]$[/wpv-conditional]
I can't find an explanation in the documentation. Am I missing something? Is there a better way to do this?
Hello. Thank you for contacting the Toolset support.
Views offers a way to be able to display the view output list inline.
You can checkmark the checkbox "Disable the wrapping DIV around the View" available just under the "Loop Editor" section to raw output the view result and then yon can use it with conditional statement.
Thank you Minesh, I've seen that checkbox a million times and it just didn't "click" for me.
The view still passed back some unexpected whitespace so I can't use the return value in my conditional. However, I moved conditionals into the count view so that it returns proper links and singular/plural. This way seems faster as the page load more quickly.