I have a repeating field setup called Apple Playlists. I want to only show the view when the repeating fields are not empty. This is the code I used, but it makes the entire view disappear even when there are non empty fields.
[wpv-conditional if="( $(wpcf-apple-playlists) ne '' )"]<div class="btn-group btn-group-view">[wpv-view name="apple-playlists"]</div>[/wpv-conditional]
Thanks
Hi, try using the Types field shortcode syntax instead:
[wpv-conditional if="( '[types field="apple-playlists" output="raw"][/types]' ne '' )"]<div class="btn-group btn-group-view">[wpv-view name="apple-playlists"]</div>[/wpv-conditional]
Thanks, that did not work. I added the code to come just before the first button, and it is not showing. See here:
hidden link
I'm not quite sure I know what I should be looking for. I see an Apply Playlists button, that includes a View. Just before that I see Oscar Hammerstein and Richard Rogers, as text links. Can you turn on debug mode and tell me if anything is shown on screen?
[wpv-conditional if="( '[types field="apple-playlists" output="raw"][/types]' ne '' )" debug="true"]<div class="btn-group btn-group-view">[wpv-view name="apple-playlists"]</div>[/wpv-conditional]
okay, debug is on
here is what it says:
1
####################
wpv-conditional attributes
####################
Array
(
[if] => ( '' ne '' )
[debug] => true
)
####################
Debug information
####################
--------------------
Original expression: ( '' ne '' )
--------------------
After replacing 1 general variables and comparing strings: ( '' ne '' )
Comparing to
So it seems to think the custom field is empty. May I log in and see how this is set up?
Oh I see now, you're talking about repeatable field groups (RFGs), not a single repeating field. I misunderstood. There's no way to use conditional HTML to test whether or not there are any RFGs associated with a post. However, you can use the Apple Playlists View like a conditional. There are two sections in a View - wpv-items-found and wpv-no-items-found. You can move your button code inside the wpv-items-found block of the View, just before the wpv-loop tags, and leave the wpv-no-items-found block empty.
Ahh, right. Perfect. My issue is resolved now. Thank you!