Problem:
How can I query all the Date-Fields and highlight the output if the Field's date was 2 days before now (TODAY)?
Solution (include the steps to follow here):
You would need a Custom ShortCode that returns "Today" as a valid date to compare with the Posts Custom field "Date".
Then, in a wpv-conditional, you can evaluate if the difference is 2 days lower than today.
Best you use Timestamp, it uses a "Amount of seconds from day xy" so you can use a very simple "lower than" evaluation.
Use something like this to return today's date in Timestamp format:
1. Use time() to get current Timestamp:
http://php.net/manual/de/function.time.php
example:
function now_func( $atts ){
$now = time();
return $now;
}
add_shortcode( 'now', 'now_func' );
2. register the new shortcode in Views > Settings > Compatibility > 3rd party Shortcodes
3. Evaluate like this wherever you want:
(assumes you already have a types custom field "date")
[wpv-conditional if="( $(wpcf-date) lt '[now]' )"]What you want to display here[/wpv-conditional]
Above will display the content only if the DATE field is LOWER than the TODAY date.
Now, if you want to evaluate if it's lower than "2 days ago", you need to set your TODAY PHP Code to return a value of 2 days ago.
This can be done like this in your "now" shortcode:
time() - 24*60*60; // per day
time() - 86400*2; //for 2 days