How to Restrict WordPress Posts for Specific Dates

In this tutorial, we show you how to restrict WordPress posts for specific dates. You can publish posts temporarily or expire posts in WordPress easily.

If you have a blog that is activated only for specific seasons such as Christmas or Easter, you can have the posts published on your site, but only give readers access during the specific season. After that season, you’ll automatically expire the posts.

This is like adding an expiration date to your WordPress posts, but you can also publish the posts periodically. That is, the same date or date range every year.

We’ll do it using the WordPress Conditional Post Restrictions plugin.

With this WordPress Plugin, you can apply a variety of conditions to create specific restrictions for your posts, pages, and any other WordPress post type. In this case, you can apply various conditions to your WordPress posts. For example, you can restrict posts by:

  • IP
  • Post Viewed Count
  • Referer
  • URL
  • User role
  • User email
  • User email company
  • Days since user registration
  • Hour of the day
  • Date
  • Day of the week
  • Day of the month
  • Month of the Year

In this example, we’ll show you how to restrict access for specific posts and for all posts. Let’s just make some ideas clear:

  • Restrict access means users won’t be able to access the posts under the selected conditions. For example, users will be able to access posts on all dates, except on the restricted date.
  • Allow access means users will be able to access the posts under the selected conditions only. For example, users will be able to access your posts on Holidays only.

You decide which method you’ll use: restrict access or allow access.

Just follow these simple steps:

1- Install the ‘WordPress Conditional Post Restrictions’ plugin

You can download the plugin here:

Download WordPress Conditional Post Restrictions Plugin - or - Read more

Once you install and activate the plugin on your WordPress website, you can proceed to easily restrict or allow your WordPress posts for specific dates.

2- Restrict WordPress posts by date GLOBALLY

If you want to apply restrictions to all posts on your website, you can easily do so. You only need to create a global condition and apply it to all the posts.

For this, you need to go to Settings > Posts Restrictions.

a) Understanding the global settings

Once there, you’ll see the following fields:

  • Enable restrictions: Tick/untick this checkbox to enable/disable the global conditions.
  • Global restrictions: Here you’ll see all the global conditions you create.
  • Don’t apply restrictions for these user roles: You’ll see a list of user roles for which the conditions won’t be applied. By default, we will not apply restrictions for administrators, editors, and any user with the capability edit_others_posts.
  • What happens when the post is restricted? You have several options to select what happens when the post is restricted:
    • Redirect to URL
    • Remove the content and show a message
    • Show fragment of the content and show message after fragment
  • What happens when a category is restricted? You have several options to select what happens when the post is restricted:
    • Show error 404
    • Show the normal page without posts
    • Show an error message
    • Redirect to another URL
    • Show the content of another page

b) Restrict posts for specific date globally

Tick the Enable restrictions checkbox.

Then, add a global condition. Just click Add conditions.

Once you open the Add Conditions form, you need to select the following values to restrict your WordPress posts globally.

  • Add new restrictions: Enter the condition title
  • Select post types: Posts
  • What happens when the conditions are met: Restrict access. You decide.
  • Condition 1: Date (YYYY-MM-DD) = 2020-10-08
  • Click Publish

The entered date is an example. You need to enter the date using the YYYY-MM-DD date format.

Important

  • If you select Allow access, users will be able to access the posts only on the date selected.
  • If you select Restrict access, users will be able to access the posts on all dates but the selected date.

c) Restrict posts by date range globally

If you want to restrict posts globally on a date range, you can do it easily with WordPress Conditional Post Restrictions. For example, you can restrict access to your posts in December only.

In this case, we’ll restrict access to our posts from December 1st to December 31st, 2020, so the conditions you need to add needs to have these values:

  • Add new restrictions: Enter the condition title
  • Select post types: Posts
  • What happens when the conditions are met: Restrict access
  • Condition 1: Date (YYYY-MM-DD) >= 2020-12-01
  • Click the + button on Condition 1 to add an “and” condition
  • Condition 1: Date (YYYY-MM-DD) <= 2020-12-31
  • Click Publish

Important

  • If you select Allow access, users will be able to access the posts only on the date selected.
  • If you select Restrict access, users will be able to access the posts on all dates but the selected date.
  • The date with the “>=” symbol is the initial date
  • The date with the “<=” symbol is the final date

3- Restrict all WordPress posts by date or date range

Maybe you don’t want to restrict all your posts, but just some individual posts. In that case, you don’t need to apply a global condition; instead, you need to edit the restrictions for each post.

Go to Posts and open the post you want to restrict.

a) Restrict individual posts for a specific date

Once you open the post, scroll down to go to Restriction rules and select these values:

  • Enable content restrictions? Yes
  • What happens when the conditions are met? Restrict access / Allow access

Now go to Restrictions and add the next condition:

  • Condition 1: Date (YYYY-MM-DD) = 2020-10-08

Finally, update the post to apply the changes.

b) Restrict individual posts by date range

If you want to restrict this specific post for a date range, you need to apply the following conditions:

  • Enable content restrictions? Yes
  • What happens when the conditions are met? Restrict access / Allow Access
  • Condition 1: Date (YYYY-MM-DD) >= 2020-12-01
  • Click the + button on Condition 1 to add an “and” condition
  • Condition 1: Date (YYYY-MM-DD) <= 2020-12-31
  • Update the post to apply the changes.

Important

  • If you select Allow access, users will be able to access this post only on the date selected.
  • If you select Restrict access, users will be able to access this post on all dates but the selected date.
  • The date with the “>=” symbol is the initial date
  • The date with the “<=” symbol is the final date

That’s really easy!

With the WordPress Conditional Post Restrictions plugin, you can easily restrict your WordPress posts for specific dates. You can create private post platforms with these easy-to-create conditions.

Something great is that you can avoid 404 errors on your site because you can easily redirect users to any specific URL when your posts are restricted.

You can download the plugin here:

Download WordPress Conditional Post Restrictions Plugin - or - Read more