![](https://i-blog.csdnimg.cn/blog_migrate/c6e1021cea7d59ebe64fcbde0fd604cd.png)
wordpress显示部分
Have you ever wished that you can set an expiration date for your blog posts? Perhaps you have timely content such as deals or giveaways that have been outdated which you want to automatically expire? In this article, we will show you how to expire posts and pages in WordPress. We will also show you how to schedule part of your post or page content to be expired after a specific date.
您是否曾经希望可以为博客文章设置过期日期? 也许您有及时的内容(例如交易或赠品)已经过时并且想要自动过期? 在本文中,我们将向您展示如何使WordPress中的帖子和页面失效。 我们还将向您展示如何安排部分帖子或页面内容在特定日期之后过期。
![Expire Post Content Expire Post Content](https://i-blog.csdnimg.cn/blog_migrate/946caa2a967d3050198cda40d07f87e7.png)
When would you want to expire posts or partial post content?
您什么时候要过期帖子或部分帖子内容?
The primary use case of post expiration is to expire time-sensitive content such as special deals, coupons, giveaways, and event announcements.
过期后的主要用例是使对时间敏感的内容(例如特价,优惠券,赠品和事件公告)过期。
In certain cases, you may want to keep the post active on your site because it is helpful, but only expire partial content such as a special limited-time discount coupon which no longer works..
在某些情况下,您可能希望使该帖子在您的网站上保持活动状态,因为它很有帮助,但只能使部分内容(例如不再有效的特殊限时折扣优惠券)过期。
First let’s take a look at how to expire posts, then we will look at how to expire partial post content.
首先让我们看一下如何使帖子过期,然后我们将看看如何使部分帖子内容过期。
影片教学 (Video Tutorial)
If you don’t like the video or need more instructions, then continue reading.
如果您不喜欢该视频或需要更多说明,请继续阅读。
如何使WordPress中的帖子过期? (How to Expire Posts in WordPress?)
There are ways to customize the WordPress loop with PHP codes and utilize custom fields to make this happen, but that is too much work. Let’s take a look at an easier solution: Post Expirator plugin.
有多种方法可以使用PHP代码自定义WordPress循环,并利用自定义字段来实现此目的,但这是太多的工作。 让我们看一个更简单的解决方案: Post Expirator插件。
First thing you need to do is install and activate the plugin. Once activate, go to edit any WordPress post or page, and you will see a new metabox like this:
您需要做的第一件事是安装并激活插件。 激活后,去编辑任何WordPress帖子或页面,您将看到一个新的metabox,如下所示:
![Post Expirator - WordPress Plugin Post Expirator - WordPress Plugin](https://i-blog.csdnimg.cn/blog_migrate/1bb541f5b3f4eba5270fec823f1b1114.png)
You can enable the post expiration and select the date / time that you want this post to expire on.
您可以启用帖子过期,并选择希望此帖子过期的日期/时间。
You are probably wondering what happens to the post once it is expired. Well, you get to decide that. There are several options to choose from.
您可能想知道帖子过期后会发生什么。 好吧,您可以决定。 有几种选择。
You can either make it a draft (unpublish it), set it to private, delete the post altogether, or you can change the post category.
您可以将其设为草稿(取消发布),将其设置为私人,完全删除帖子,或者可以更改帖子类别。
You also have additional settings that you can configure from the settings page found under Settings » Post Expirator.
您还可以从“设置”»“ Post Expirator”下的“设置”页面配置其他设置。
![Post Expirator Settings - WordPress Plugin Post Expirator Settings - WordPress Plugin](https://i-blog.csdnimg.cn/blog_migrate/835b174de5fd9b2faa141a6d21f11061.png)
You can choose the date and time format along with the default expiration category. You also have the option to add the post expiration date at the end of your content to let your users know when this post or page will be expiring.
您可以选择日期和时间格式以及默认的到期类别。 您还可以选择在内容的末尾添加帖子的过期日期,以使您的用户知道帖子或页面的过期时间。
![Post Expirator Footer Settings - WordPress Plugin Post Expirator Footer Settings - WordPress Plugin](https://i-blog.csdnimg.cn/blog_migrate/a314527ca9dab32ddb7b50f8c13ff97d.png)
Another plugin that offers similar functionality is called Simple Post Expiration.
另一个提供类似功能的插件称为Simple Post Expiration 。
如何使WordPress中的部分帖子内容过期 (How to Expire Partial Post Content in WordPress)
The above method shows you how to expire the entire post or page, but in some cases that is not what you want. You may just want to remove part of the post or page content after a certain time. Well in that case, the plugin called Scheduled Content is your best solution.
上面的方法显示了如何使整个帖子或页面失效,但是在某些情况下,这不是您想要的。 您可能只想在一段时间后删除部分帖子或页面内容。 在这种情况下,名为“ 计划内容”的插件是您最好的解决方案。
This plugin allows you to schedule part of your post content to be published and expired based on the dates you specify.
使用此插件,您可以根据指定的日期安排要发布和过期的部分帖子内容。
First thing you need to do is install and activate the plugin. Once you have done that, there are no additional settings. All you need to do is wrap your content with the shortcode and set the date/time you’d like it to expire on. When that time arrives, this content will disappear and no longer be visible to your users.
您需要做的第一件事是安装并激活插件。 完成此操作后,便没有其他设置了。 您所需要做的就是用短代码包装内容,并设置您希望其过期的日期/时间。 时间到了,此内容将消失并且对您的用户不再可见。
[schedule on=’2014-12-01′ at=”10:01″ expon=’2014-12-01′ expat=”13:15″] the content you want to hide here [/schedule]
[schedule on ='2014-12-01'at =“ 10:01” expon ='2014-12-01'expat =“ 13:15”]您要在此处隐藏的内容[/ schedule]
The date has to be set in yy-mm-dd format, and time has to be set in the 24 hours format.
日期必须以yy-mm-dd格式设置,而时间必须以24小时格式设置。
The time is compared with your blog’s time zone settings, so make sure you have the right time zone by going to Settings » General.
将时间与博客的时区设置进行比较,因此请转到“设置”»“常规”,确保您具有正确的时区。
You can also add shortcodes inside this schedule shortcode as well.
您也可以在此计划简码中添加简码。
We hope this article helped you learn how to expire posts in WordPress and expire partial post and page content in WordPress.
我们希望本文能帮助您学习如何使WordPress中的帖子过期以及如何使WordPress中的部分帖子和页面内容过期。
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在Twitter和Facebook上找到我们。
翻译自: https://www.wpbeginner.com/plugins/how-to-expire-posts-or-partial-post-content-in-wordpress/
wordpress显示部分