In this post, we will show you how to add temporary access restriction to your WordPress posts.
For example, let’s say you want to edit WordPress posts so that visitors can’t read them for the entire month of January 2024, but you don’t want to move them to draft or unpublish them.
You just want to restrict access to the posts temporarily.
This is a great way to publish posts temporarily or automatically “expire” posts on WordPress.
It can be really useful if you have a blog containing seasonal content like Christmas or Easter content, and you want to restrict access to your posts for other seasons of the year.
WordPress Conditional Post Restrictions
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.
You can download the plugin here:
Download WordPress Conditional Post Restrictions Plugin - or - Read more
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 to specific posts or to all posts by date range.
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.
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. You can add new conditions by clicking on Add conditions.
- 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
- Remove restricted posts from menus: This removes the posts from navigation menus in case you have added any restricted post to your nav menus.
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.
- Condition 1: Date (YYYY-MM-DD) = Select the date. In this example, we will enter 2024-01-18 because we want the access to this post to be restricted on January 18, 2024.
- 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 January 1st to January 31st, 2024, 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) >= Here you need to select the date. We will select: 2024-01-01
- Click the + button on Condition 1 to add an “and” condition
- Condition 1: Date (YYYY-MM-DD) <= Here you need to select the date. We will select: 2024-01-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) = 2024-01-18, for example.
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:
- 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) >= Here you need to select the date. We will select: 2024-01-01
- Click the + button on Condition 1 to add an “and” condition
- Condition 1: Date (YYYY-MM-DD) <= Here you need to select the date. We will select: 2024-01-31
- Update the post to save 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
Restrict access to WordPress posts temporarily
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