Widgets are the easiest way to add custom items to your WordPress sidebars or widget-ready areas. You can customize widget display with Widget Logic, hide widget titles, and you can even display widgets in post or page content. WordPress Widgets are just as customizable, as WordPress itself. In this article, we will show you how to set an expire date for widgets in WordPress.
窗口小部件是将自定义项目添加到WordPress 边栏或窗口小部件就绪区域的最简单方法。 您可以使用Widget Logic 定制窗口小部件显示 , 隐藏窗口小部件标题 ,甚至可以在帖子或页面内容中显示窗口小部件 。 WordPress小部件与WordPress本身一样可自定义。 在本文中,我们将向您展示如何为WordPress中的小部件设置过期日期。
什么时候需要设置小部件的失效日期? (When You Need To Set an Expire Date for Widgets?)
Sometimes you may want to run a promotional campaign on your website, a campaign that expires at a given time. By setting up an expiration date for the widget, you can hide it from the users when the campaign is over. There can be many other uses, like for example hiding ads when their time slot is over, or hiding seasonal widgets during holidays.
有时您可能想在网站上运行促销活动,该活动在给定时间到期。 通过设置窗口小部件的到期日期,您可以在广告活动结束后向用户隐藏它。 还有许多其他用途,例如,当广告时段结束时隐藏广告,或在假期期间隐藏季节性窗口小部件。
影片教学 (Video Tutorial)
If you don’t like the video or need more instructions, then continue reading.
如果您不喜欢该视频或需要更多说明,请继续阅读。
To set up expire date for widgets in WordPress all you need to do is install and activate the Dynamic Widgets plugin. After activation, you need to go to Appearance » Dynamic Widgets area. There you will see all your currently displayed widgets in their respective sidebars.
要为WordPress中的小部件设置过期日期,您需要做的就是安装并激活Dynamic Widgets插件。 激活后,您需要转到外观»动态窗口小部件区域。 在此处,您将在各自的侧栏中看到所有当前显示的小部件。
![Dynamic Widgets Screen Dynamic Widgets Screen](https://i-blog.csdnimg.cn/blog_migrate/7a1f58f4b12b430f738f3a582898366e.png)
To set an expiration date for a widget, simply click on the edit link below the widget title. This will open the widget in the Dynamic Widget’s widget editor. Now you need to click on the date option and select No under ‘Show widget always?’ option. Below it you can set a display duration for the widget.
要设置小部件的失效日期,只需单击小部件标题下方的编辑链接。 这将在动态窗口小部件的窗口小部件编辑器中打开窗口小部件。 现在,您需要单击日期选项,然后在“始终显示小部件?”下选择“ 否 ”。 选项。 在它下面,您可以设置小部件的显示持续时间。
![Setting up an expire date for a Widget in WordPress Setting up an expire date for a Widget in WordPress](https://i-blog.csdnimg.cn/blog_migrate/fa3f10658f93b4d1e23cd3b46bf98b3b.png)
The widget will expire when it reaches the end date. Upon expiration your widget will still be available under admin section, but it will not be displayed publicly on your site.
窗口小部件在到达结束日期时将过期。 过期后,您的小部件仍将在“管理”部分下可用,但不会在您的网站上公开显示。
Dynamic Widgets can also be used to set other conditional rules on widget display. For example, you can display a widget on certain sections of your website, or you can set to display a widget on certain days of the week, month, etc.
动态窗口小部件还可以用于在窗口小部件显示上设置其他条件规则。 例如,您可以在网站的某些部分上显示小部件,或者可以设置在一周中某个月,某月的某些天显示小部件。
We hope this article helped you gain more control over WordPress widgets. What other features would you like to see in WordPress widgets to make them more dynamic and powerful?
我们希望本文能帮助您更好地控制WordPress小部件。 您还想在WordPress小部件中看到哪些其他功能,以使其更加动态和强大?
Let us know by leaving a comment below or join us on Twitter.
通过在下面发表评论让我们知道,或者在Twitter上加入我们。
翻译自: https://www.wpbeginner.com/plugins/how-to-set-expire-date-for-widgets-in-wordpress/