Skip Navigation

[Resolved] Content template usage conditional not working

This support ticket is created 2 years, 6 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by manakM 2 years, 5 months ago.

Assisted by: Waqar.

Author
Posts
#2437183
Screenshot 2022-08-13 at 7.26.44 PM.png

The following conditional is being rejected in the advanced editor with the error "Please, complete all the conditions or remove them".

(('[types field="deadline" output="raw"][/types]' gt 'NOW()') OR (('[types field="deadline" output="raw"][/types]' lte 'NOW()') AND ('[types field="archive" output="raw"][/types]' eq '0')))

#2437971

Hi,

Thank you for contacting us and I'd be happy to assist.

To troubleshoot this on a test website and suggest an efficient way to achieve this, I'll need to see precisely how the involved custom fields are set up.

Can you please share the temporary admin login details of the website?

Note: Your next reply will be private and though no changes will be made on your website, making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2438995

Thank you for sharing the access details.

I understand that the "deadline" is a date/time type field, whereas the "archive" is a checkbox type field.

During testing on my website, I couldn't make the template level conditional assignment work with the date/time type custom field or even evaluate it based on a custom shortcode that process these field values, in the background.

To achieve something like this, you'll need to distribute your content for the "Get Involved" post type into 3 different content templates:

1. The main "Get Involved Template" will be assigned to all the "Get Involved" posts.

In this template, you'll add two conditional blocks, one for when your desired condition is true and the other when it is false.

The condition that you're trying to evaluate should be fairly simple when used from inside the conditional blocks.

True condition:


  ( ( $(wpcf-deadline) gt 'NOW()' ) OR   ( ( $(wpcf-deadline) lte 'NOW()' ) AND ( $(wpcf-archive) eq '0' ) )  ) 

False condition:


  NOT ( ( $(wpcf-deadline) gt 'NOW()' ) OR   ( ( $(wpcf-deadline) lte 'NOW()' ) AND ( $(wpcf-archive) eq '0' ) )  ) 

2. You'll create a second content template named "Get Involved Template - Condition True" that will hold only the content that should be shown when the condition is true.

3. After that, you'll create a third content template named "Get Involved Template - Condition False" that will hold only the content that should be shown when the condition is false.

Once these content templates are ready, you'll add them in the respective conditional blocks, added in the main "Get Involved Template", so that each one is loaded only when the condition is true or false.

I hope this makes sense and let me know if you need any further assistance around this.

#2441967

This solution works. Thank you Waqar! Sorry for the delay in closing this.