Skip Navigation

[Resolved] Conditional to show something if a post is less than 7 days old

This support ticket is created 3 years 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.

Our next available supporter will start replying to tickets in about 7.02 hours from now. Thank you for your understanding.

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 2 replies, has 2 voices.

Last updated by nickH-5 3 years ago.

Assisted by: Waqar.


Could you tell me what is wrong with this conditional to show something if a post is less than 7 days old? [wpv-post-date format="U"][wpv-conditional if="( '([wpv-post-date format="u"]+(7*24*60*60))' gt 'NOW()' )"]NEW[/wpv-conditional]



Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)


During troubleshooting, I noticed two issues with the conditional block that you've shared:

1. The small 'u' was used in the format attribute and not the capital 'U', which represents the UNIX timestamp.
( hidden link )

2. The sum and multiplication operation can't be performed within the conditional evaluation.

To achieve this you can register a custom shortcode that can return the post date with the addition of 7 days. For example:

add_shortcode('seven_day_check', 'seven_day_check_func');
function seven_day_check_func() {
	$post_date = do_shortcode('[wpv-post-date format="U"]');
	$post_date_plus_7 = intval($post_date)+ intval(7*24*60*60);

	return $post_date_plus_7;

The above code snippet can be included through either Toolset's custom code feature ( ref: ) or through active theme's "functions.php" file.

Next, please add "seven_day_check" in the "Third-party shortcode arguments" section, at WP Admin -> Toolset -> Settings -> Front-end Content.

After that, you'll be able to use this new shortcode in a conditional check, like this:

[wpv-conditional if="( '[seven_day_check]' gt 'NOW()' )"]NEW[/wpv-conditional]



Thanks. I didn't understand that it was not possible to evaluate in a condition.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.