[Condition] Published in last X days

A new snippet that allows you to show or hide content based on if the post was published in the last X days. The snippet defaults to last 7 days, however this can be configured in the function arguments.

How to use

If you are using Gutenberg, you can use a similar method to this post for creating and adding conditions to your blocks.

If you are using Oxygen Builder, you can use the condition builder and the PHP return value option and passing the function name and number of days as the argument.

The code

There are two snippets here which are slightly modified. The first one works based on the post date, the second works based on an ACF date field.

Members content only

Become a SnippetClub member to gain instant access to this tutorial plus tons more premium content.

Already a member? Log in below.

👋🏻 Weekly Tutorial Digest

I send out a weekly newsletter with links to new tutorials written in the last week, you can subscribe below.

🔒I won't send you spam, I promise