WordPress gives you complete control over your content. However, there are times when you want posts to disappear automatically, such as for limited-time offers, event announcements, or outdated news. Knowing how to set posts or parts of posts to expire can be invaluable. Instead of manually deleting content, you can schedule it to be hidden or removed after a specific date. This feature is particularly useful for date-sensitive promotions or seasonal updates.
Whether it’s a full post or just a section, content expiry helps keep your website current. You can manage expiry using plugins or shortcodes, and with the right tools, WordPress allows you to customize how content behaves over time. Understanding these methods can boost user engagement and improve SEO. Let’s explore easy ways to make full posts or parts of posts fade away automatically.
Plugins simplify content expiration. There’s no need to write code or change templates. Just install and activate the appropriate plugin. Post Expirator is a popular choice. This free plugin adds an expiry attribute to your posts. Once installed, open any post in edit mode, and you will find an expiration panel. Select a date and time for the post to expire. You can choose to draft, trash, make private, or permanently delete. The plugin supports posts, pages, and custom types, and you can set it globally or per post. It also includes an optional expiration notice to inform readers.
In addition to supporting categories and tags, it lets you remove or edit them upon expiry. This program makes expiring WordPress content simple, offering total control and user-friendliness. For advanced scheduling, there is a Pro edition, but the free version is sufficient for basic use. It’s regularly updated and compatible with most themes.
Not everyone wants to use plugins; some prefer native or manual approaches. While WordPress allows you to schedule post publication, it doesn’t directly support expiration control. However, you can achieve similar results. First, create a new post to replace the existing one and schedule it for a later date. Simultaneously, edit the older post and change its status to private or draft on the same day. This can be done manually using a reminder program or calendar tool.
Although this method is not automated, it offers complete control. For partial content, use custom fields or page builders. For instance, Elementor allows you to set widgets to vanish after a deadline using date rules for display conditions. This provides another approach for WordPress content to expire without additional plugins. A developer can also use cron jobs, though most users will find manual methods acceptable. They are simple, neat, and safe for small sites.
Sometimes, you might want only a portion of a post to expire. Shortcodes can help with that. Certain plugins let you enclose post sections in expiry tags. Using Shortcodes Ultimate or a similar tool that supports time-based visibility is one option.
Place the content you wish to expire inside a shortcode, such as [expire date="2025-08-01"]Your content here[/expire]
. The shortcode hides or replaces the content when the expiration date arrives. You can add several shortcodes to different parts of the same post. This is ideal for countdowns, notices, or limited-time offers, while the rest of your post remains visible.
WP Cron handles background operations like content verification and publication. It can automate post expiration without needing plugins. Create a function that modifies the post status when the date matches, executing at a specified time. Start by using wp_schedule_event()
to schedule a task, then connect it to a custom function that changes the status of posts containing an expiry_date
. The function can run hourly, twice daily, or daily.
This approach is highly adaptable. You have control over the post’s fate and the frequency of the expiry task. Since no additional plugins are needed, it keeps your website lightweight. Using WP Cron to run cleanup jobs ensures content remains up to date, especially if your site contains many outdated articles.
Instead of deleting content, you can schedule post updates. This is useful when articles require minor edits rather than complete removal. For timed content replacement, use features within tools like Elementor Pro or Divi, or plugins like Post Scheduler. You can choose to change calls-to-action, add new information, or update text. This keeps your article current and reflects the latest data. It’s a useful tactic for evergreen articles that occasionally need revisions. By using time-based updates, your readers will always receive fresh and helpful content.
This technique automates the process if you frequently edit articles. For more control, use WP Cron or shortcodes alongside it. Scheduled content changes provide better long-term results, whether for price updates or deadline adjustments.
JavaScript can also expire post content. You can add a date check in the HTML of your post, concealing the content from view after the date has passed. This keeps the content hidden from users without removing it from your source code. It’s simple and non-destructive. For example, wrap the content in a div
with an expiry attribute. Use JavaScript to compare the current date with the expiration date.
If the content has expired, you can either hide the div or replace it with a message. This method doesn’t require server-side access, making it ideal for those with limited backend control or static websites. Additionally, you can integrate it with block editors or page builders using custom HTML blocks. JavaScript allows you to control what users see in marketing articles or short-term promotions without affecting your WordPress files or database.
In WordPress, expiring posts or partial content is simpler than many users believe. Each method provides control, whether you use plugins, shortcodes, or custom PHP. By automating outdated article management, your website remains current and organized. You can apply expiration criteria to entire posts or just portions. Choose the strategy that best fits your needs. These tools will help you quickly remove obsolete items, keeping your blog cleaner, faster, and more relevant. Only expire what is no longer beneficial; you don’t have to delete everything.