Hello.
CPT: Games
Date Field: start-of-game
Custom Shortcode (registered on Views -> Setting page): currentdate
function currentdate(){
return current_time('zHi');
}
add_shortcode('currentdate', 'currentdate');
Our Conditional statement:
[wpv-if gametime="[types field='start-of-game' style='text' format='YmdHi'][/types]" evaluate="$gametime > [currentdate]"]Game Over[/wpv-if]
Debug example:
Attributes: {"gametime":"201409061100","evaluate":"$gametime > 201408311722"}
Info: Conditional output: evaluated to false
Regardless of the 'currenttime', the $gametime is evaluating as less than 'currenttime' as it is a string of text.
If we do not use the argument and write the Conditional Statement as:
[wpv-if evaluate="[types field='start-of-game' style='text' format='YmdHi'][/types] < [currentdate]"]Game Over[/wpv-if]
Debug:
Attributes: {"evaluate":"201408301800 < 201408311735"}
Info: Conditional output: evaluated to true
Output: Game Over
It functions correctly (but seems wrong based on the quotes and apostrophes, see attachment). What is wrong with the args in the first Conditional Statement?
Thanks
Dear Rob,
You aren’t using the syntax correctly in the first instance, the correct way is:
[wpv-if gametime="wpcf-start-of-game" evaluate="$gametime > [currentdate]"]Game Over[/wpv-if]
But with this syntax you can’t control the format of the date.
In your second example you are doing it correctly.
Don’t worry about the quotes. The inner short codes are replaced first, which leaves the quotes correct for a second pass.
Please let me know if you are satisfied with my reply and any other questions you may have.
Regards,
Caridad