Skip Navigation

[Resolved] conditional output from child post in parent view

This support ticket is created 4 years, 9 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.

Our next available supporter will start replying to tickets in about 1.12 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 7 replies, has 2 voices.

Last updated by Christian Cox 4 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1505629

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]

#1505841

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.

#1506051

Thanks so much! I just tried and it did not work...

#1507321

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?

#1507347
Screen Shot 2020-02-13 at 9.01.26 AM.png
Screen Shot 2020-02-13 at 9.01.34 AM.png
Screen Shot 2020-02-13 at 9.06.50 AM.png
Screen Shot 2020-02-13 at 9.07.04 AM.png
Screen Shot 2020-02-13 at 9.00.14 AM.png

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)

#1507581

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.

#1507803

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!

#1507811

Excellent! Feel free to resolve here or let me know if you have follow up questions about this.