Skip Navigation

[Resolved] Need to display a multiple custom field with only future date

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.

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

Problem: I would like to loop over repeating custom fields and display each field conditionally using wpv-conditional.

Solution: The wpv-conditional shortcode will not be effective in a for-each loop. The best solution is to write a custom shortcode that performs this type of operation.

Relevant Documentation: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-for-each

This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

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 4 replies, has 2 voices.

Last updated by Jean-Marie Clément 6 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#545649

I am trying to: within a view display a multiple date field where date is only from today

I visited this URL: hidden link

I expected to see: future date below "partenza" on home page.

Instead, I got: blank or all date

My problem is similar to both:
https://toolset.com/forums/topic/input-and-display-multiple-date-values/
and
https://toolset.com/forums/topic/date-field-multiple-instances-show-only-today-or-higher/

it seems that not solved, here is what I would have to work:

          [wpv-for-each field="wpcf-data-partenza"]
          	[wpv-conditional if="($(data-partenza) gt TODAY())"]          		
          		<br />[types field="data-partenza"  style="text" format="d M Y"][/types]        
          	[/wpv-conditional]
          [/wpv-for-each]

wpv-conditional of wpv-if within a wpv-for-each loop should solve the problem

I would avoid to create a child custom field only for date.

Jean-Marie

#545687

Hi, unfortunately wpv-conditional shortcodes will not work inside a wpv-for-each loop. This is documented in the shortcode information here: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-for-each

I think the only way to accomplish this would be to write a custom shortcode which will loop over the repeating date fields of the current post and return only the future dates, formatted appropriately.

#546141

Hi Cristian,

I have read before than wpv-conditional wasn't working within a loop, so I asked if there was a different solution 😉
I'll probably do my own shortcode as you said and I'll be back to you if I need further assistance.
Thanks

#546566

Okay let me know how you would like to proceed. I will mark this ticket as pending an update from you.

#548283

I solved by doing a custom shortcode.
Thanks for support

The forum ‘Types Community Support’ is closed to new topics and replies.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.