I have a parent CPT: SHOWS
with 2 children: BANDS, VENUES
I am creating a view for shows that should show specific info from BANDS and VENUES if it is not blank -
so normally (if I was creating a view for the VENUE) I would use this code. But since I'm creating a view for the child, this is not working. What am I missing?
[wpv-conditional if="( $(wpcf-venue-logo) ne '' )"]<div class="circle-logo">[types field='venue-logo' title='%%TITLE%%' alt='%%ALT%%' size='full' item='@show-venue.child' ][/types]</div>[/wpv-conditional]
Hi, you can use the Types field shortcode directly in the conditional like this:
[wpv-conditional if="( '[types field="venue-logo" title="%%TITLE%%" alt="%%ALT%%" size="full" item="@show-venue.child" ][/types]' ne '' )"]<div class="circle-logo">[types field='venue-logo' title='%%TITLE%%' alt='%%ALT%%' size='full' item='@show-venue.child' ][/types]</div>[/wpv-conditional]
Note that I modified the quotation marks to work in the conditional syntax. Let me know if this isn't working as expected and I can take a closer look.
Thanks so much! I just tried and it did not work...
Okay let me be sure I understand. You're creating a View of Venues and you want to insert a conditional that tests a field in the parent Show post? Or a field in the Venue post? Or a field in a sibling Band post?
OK, yes, sorry if I'm not speaking the correct terms. Soooo... here are my relationships (See screenshots as well)
Post types are:
SHOWS
BANDS
VENUES
Shows has a many-to-many relationship with Bands
Shows has a many-to-many relationship with Venues
(not sure if that is set up the best way for my usage...?)
I am creating a page for SHOWS
on that page, I have a time/date and then a band and a venue. The page will show some fields from each child (or) sibling (?)
So the page will have the logo, address, image from the venue as well as the image, some youtube and social media links from the Band.
A lot of these fields may be blank, so I need to substitute a placeholder or not whos it at all (ie an icon or div class for the images/social links)
Okay so you'll have one View of Venues related to the current Show, and one View of Bands related to the current Show. In the View of Venues, if you want to use a conditional in that View's loop based on the current Venue's custom fields, that would look like this:
[wpv-conditional if="( $(wpcf-venue-logo) ne '' )"]<div class="circle-logo">[types field='venue-logo' title='%%TITLE%%' alt='%%ALT%%' size='full' ][/types]</div>[/wpv-conditional]
This assumes the venue-logo field is part of the Venue post.
You would do something similar for the View of Bands.
ohhhhh.... I see. So I just needed to make a separate view - I had that same code, I was just trying to use it directly on the show view.
OK, phew. I have it working now. Thank you!
Excellent! Feel free to resolve here or let me know if you have follow up questions about this.