Skip Navigation

[Resolved] How to display [wpv-conditional] content based on intermediary post type custom field

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

Problem:
How to display [wpv-conditional] content based on intermediary post type custom field

Solution:
To display the intermediary post type custom field, you will have to use the types shortcode as given under:

[types field='your-field' output='raw' item='@post-venue.intermediary'][/types]

To use the intermediary post type custom field with [wpv-conditional] shortcode, You can find proposed solution, in this case with the following reply:
https://toolset.com/forums/topic/how-to-apply-wpv-conditional-to-code-in-loop-item-template/#post-2229849

Relevant Documentation:

This support ticket is created 3 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 5 replies, has 2 voices.

Last updated by chantalM 3 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#2229689

Tell us what you are trying to do?

I want to implement the following Conditional checks on a different view on my site:
https://toolset.com/forums/topic/hide-a-view-using-old-fashioned-views-not-conditional-blocks/

However my new view has the grid code in the Loop Editor:
<div class="row">
<wpv-loop>
<div class="col-md-6 col-xl-4">
[wpv-post-body view_template="loop-item-in-category-area-page"]
</div>
</wpv-loop>
</div>

The Loop Item code is in the Template for the View... and no matter where I put this Conditional code the whole thing disappears.
The code in the link above is the same code that I am using but instead of the Loop Editor it is in the Loop Item... how do I make this work?

Should I have both the grid code and loop item code in the Loop Editor so that I can apply this conditional check? Thanks.

What is the link to your site?
hidden link

#2229727

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

As shared by Waqar with previous ticket, you should wrap the view's loop code as given under:

<div class="row">
<wpv-loop>
[wpv-conditional if="( $(wpcf-booking-until) gte 'TODAY()' )"]
<div class="col-md-6 col-xl-4">
[wpv-post-body view_template="loop-item-in-category-area-page"]
</div>
[/wpv-conditional]
</wpv-loop>
</div>

Can you please try that and see if that works as expected.

#2229745

Hi Minesh,

The whole grid disappears from the page (link above)

#2229765

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You want to compare the custom date field with today's date - correct?

Can you please clear your requirement first and share admin access details so I can check whats going wrong with your setup..

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2229849

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I checked and I see that you set your view to display posts from post type "Shows":
=> hidden link

And the custom field 'booking-until' is the part of intermediary post type. To access the intermediary post type custom field value you will have to use the shortcode:

[types field='booking-until' output='raw' item='@post-venue.intermediary'][/types]

So, I've adjusted the conditional shortcode as given under:

<div class="row">
<wpv-loop>
[wpv-conditional if="( '[types field='booking-until' output='raw' item='@post-venue.intermediary'][/types]' gte 'TODAY()' )"]
<div class="col-md-6 col-xl-4">
[wpv-post-body view_template="loop-item-in-category-area-page"]
</div>
[/wpv-conditional]

</wpv-loop>
</div>
 

I can see its working now: hidden link

Can you please confirm it works at your end as well.

#2229853

My issue is resolved now. THANK YOU.