Check If The Latest Post Was Published in The Last X Minutes

In this Pro tutorial we shall define a custom function that takes in the number of minutes as an argument and returns true if there is at least 1 post in the specified minutes.

Ex.: Render a Bricks Section only if the last post has been published within the last 2 hours.

Add the following in child theme‘s functions.php (w/o the opening PHP tag) or a code snippets plugin:

We are setting 60 minutes or 1 hour as the default parameter for the function – meaning if no argument is provided when the function is called it will check if there’s a published post in the last hour.

To use this function in Bricks:

{echo:bl_has_published_post_in_last}

To specify a different time like 2 hours, enter it in minutes like this:

{echo:bl_has_published_post_in_last(120)}

Reference

https://wpdevdesign.com/date-and-time-in-wordpress-dev-notes/