I have this piece of code running successfully in a view so that if it is NOT between the 2 times entered currently, it will redirect to another page. However, the redirect is not instant. My conditional statement in the view is:
[wpv-conditional if="( $(wpcf-publish-note-date) lte '[get_current_timestamp]' ) AND ( $(wpcf-unpublish-note-date) gte '[get_current_timestamp]' ) " evaluate="false"]
[redirect url='/notes?church=central' sec='0']
[/wpv-conditional]
However even with the shortcode in there for redirecting set to 0, the original post still shows for a second on the page, before redirecting. I need to avoid that. So how do I set that conditional statement to redirect to a page without a delay?
Hello,
There isn't such kind of built-in feature within Toolset plugins, it needs custom codes, for example, you can use WordPress built-in action hook "template_redirect" to trigger a PHP function:
https://developer.wordpress.org/reference/hooks/template_redirect/
In this PHP function, check if it is your single custom post:
https://developer.wordpress.org/reference/functions/is_singular/
Get the those two custom date field values:
https://developer.wordpress.org/reference/functions/get_post_meta/
Compare them with current timestamp
https://developer.wordpress.org/reference/functions/current_time/
Then redirect to other URLs:
hidden link