Skip Navigation

[Resuelto] Using wpv-conditional with a date calculation?

This support ticket is created hace 5 años. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por Gerard hace 5 años.

Asistido por: Minesh.

Autor
Mensajes
#1389143

I am using a View to display the latest GRADE (CPT) in another view.. Everything works perfectly.

The last touch is to have those cells get the class of "late" if the post date of that grade is older than 90 days ago..

So far I have this:

[wpv-conditional if="( '[wpv-post-date]' lt 'MONTHS_FROM_NOW(-3)' )"]
<td class="late">[types field="session"][/types] [types field="year"][/types]</td>
<td class="late">[types field="gpa"][/types] / [types field="gpa-total"][/types]</td>
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-date]' gte 'MONTHS_FROM_NOW(-3)' )"]
<td>[types field="session"][/types] [types field="year"][/types]</td>
<td>[types field="gpa"][/types] / [types field="gpa-total"][/types]</td>
[/wpv-conditional]

But I suspect the MONTHS_FROM_NOW( ) function doesn't work here..

How should I go about it?

#1389289

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Yes - you can use the MONTHS_FROM_NOW(-3) as this will return the timestamp of the date from the current date timestamp minus 3 months.

So, the only change you need to make is you need to compare the publish date's timestamp. You can get the publish date timestamp by using the format attribute. For example: [wpv-post-date format='U']

For example:

[wpv-conditional if="( '[wpv-post-date format='U']' lt 'MONTHS_FROM_NOW(-3)' )"]
<td class="late">[types field="session"][/types] [types field="year"][/types]</td>
<td class="late">[types field="gpa"][/types] / [types field="gpa-total"][/types]</td>
[/wpv-conditional]

[wpv-conditional if="( '[wpv-post-date format='U']' gte 'MONTHS_FROM_NOW(-3)' )"]
<td>[types field="session"][/types] [types field="year"][/types]</td>
<td>[types field="gpa"][/types] / [types field="gpa-total"][/types]</td>
[/wpv-conditional]

More info:
=> https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-date

#1389307

Wow, so easy, I'd not seen that -U switch. Ohh it's the UNIX timestamp. W00t!

My issue is resolved now. Thank you very much!!