[WordPress] 外掛分享: Show/Hide Content at Set Time

WordPress 外掛 Show/Hide Content at Set Time 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Show/Hide Content at Set Time」是 2011-06-23 上架。
  • 目前有 10000 個安裝啟用數。
  • 上一次更新是 2019-10-01,距離現在已有 2041 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 2.5 以上版本才可以安裝。
  • 有 33 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

thewanderingbrit |

外掛標籤

date | time | active | expire | show hide |

內容簡介

喜歡這個外掛嗎?請考慮留下評論或寫下你在網站上使用它的經驗–如果你這樣做,請給我一個連結。

這個外掛在 GitHub 維護,歡迎使用存儲庫報告問題,提交功能請求和拉取請求。

此外掛提供了短代码,讓你可以在指定的日期和時間顯示或隱藏內容。你也可以結合這兩個動作,在一個時間顯示一些內容,然後在另一個時間隱藏它。

如果你想要重複一個日程以顯示和隱藏內容,也有另外一個短碼 –例如只在廣播節目時顯示有關該節目的資訊。

用法 – 單次使用

要在某個時刻顯示或隱藏內容,你可以使用[time-restrict]短碼。例如:

[time-restrict off="2015-01-01"]請參加我們的比賽[/time-restrict]
[time-restrict on="2015-01-01"]抱歉,這項比賽已經結束了[/time-restrict]

如果你在日期中沒有輸入時間,它會預設為 00:00:00,因此在上面的例子中,第一條消息將顯示到 2015-01-01 00:00:00(即在 2015 年的第一秒之前),而第二條消息則會在 2015-01-01 00:00:00(即在 2015 年的第一秒之後)顯示。

你可以使用任何日期或時間字符串,支援 PHP,例如:

[time-restrict off="September 10th, 2014"]將顯示至 09/10/2014[/time-restrict]
[time-restrict off="2014-09-10"]將顯示至 09/10/2014[/time-restrict]
[time-restrict off="10-Septmber 2014"]將顯示至 09/10/2014[/time-restrict]
[time-restrict on="2014/09/10 18:00:00"]將在 09/10/2014 的晚上 6 時後顯示[/time-restrict]

你也可以結合開始和結束日期顯示相同的內容。因此,如果你想讓一些內容在一月1日至一月10日之間顯示,可以這樣做:

[time-restrict on="2015-01-01" off="2015-01-11"]
這是有限時促銷
[/time-restrict]

用法 – 重複日程

要在重複日程上顯示和隱藏內容,可以使用[time-restrict-repeat]短碼。你可以選擇每天、每週、每月或每年。

每天日程的形式如下:

[time-restrict-repeat type="daily" ontime="09:00:00" offtime="17:00:00"]
從 9 到 5 工作
[/time-restrict-repeat]

請注意,你也可以跨越午夜,所以如果你只想顯示從晚上10點到早上5點的內容,可以使用:

[time-restrict-repeat type="daily" ontime="22:00:00" offtime="05:00:00"]
獻給夜貓族
[/time-restrict-repeat]

每週日程的形式如下:

[time-restrict-repeat type="weekly" onday="Monday" offday="Friday"]
工作一周
[/time-restrict-repeat]

如果需要,你可以指定開始和結束時間(如果不指定,它將假設從00:00:00開始,到23:59:59 結束):

[time-restrict-repeat type="weekly" onday="Friday" offday="Monday" ontime="17:00:00" offtime="08:00:00"]

原文外掛簡介

Like this plugin? Consider leaving a quick review or writing about how you’ve used it on your site – send me a link to that write up if you do.
This plugin is maintained on GitHub, so feel free to use the repository for reporting issues, submitting feature requests and submitting pull requests.
This plugin provides shortcodes allowing you to display content or hide content at given dates and times. You can also combine the two to show some content at a given time, and then hide it at another time.
There’s also a separate shortcode if you want to repeat a schedule for showing and hiding content – for example to only show information about a radio show while it’s on air.
Usage – single use
To show or hide content at one point in time, you can use the [time-restrict] shortcode. For example:
[time-restrict off="2015-01-01"]Please enter our competition[/time-restrict]
[time-restrict on="2015-01-01"]Sorry, this competition has closed[/time-restrict]

If you do not enter a time with the date, it will default to 00:00:00, so in the above example, the first message will show up until 2015-01-01 00:00:00 (i.e. until the first second of 2015) and the second message will show up from 2015-01-01 00:00:00 (i.e. from the first second of 2015)
You can use any date or time string supported by PHP, such as:
[time-restrict off="September 10th, 2014"]Will display until 09/10/2014[/time-restrict]
[time-restrict off="2014-09-10"]Will display until 09/10/2014[/time-restrict]
[time-restrict off="10-Septmber 2014"]Will display until 09/10/2014[/time-restrict]
[time-restrict on="2014/09/10 18:00:00"]Will show after 09/10/2014 at 6pm[/time-restrict]

You can also combine starting and ending dates for the same piece of content. So if you want some content to appear between January 1st and January 10th, you could do the following:
[time-restrict on="2015-01-01" off="2015-01-11"]
This is a limited time offer
[/time-restrict]

Usage – repeating schedule
To show and hide content on a recurring schedule, you can use the [time-restrict-repeat] shortcode. Your options are a daily, weekly, monthly or annual schedule.
A daily schedule takes the following form:
[time-restrict-repeat type="daily" ontime="09:00:00" offtime="17:00:00"]
Working 9 to 5
[/time-restrict-repeat]

Note that you can also cross over midnight, so to only show something from 10PM to 5AM, you can use:
[time-restrict-repeat type="daily" ontime="22:00:00" offtime="05:00:00"]
For the night owls
[/time-restrict-repeat]

A weekly schedule takes the following form:
[time-restrict-repeat type="weekly" onday="Monday" offday="Friday"]
The work week
[/time-restrict-repeat]

You can also specify start and stop times if you want (it will assume starting at 00:00:00 and ending at 23:59:59 if these are left out, like above):
[time-restrict-repeat type="weekly" onday="Friday" offday="Monday" ontime="17:00:00" offtime="08:00:00"]
It's the weekend baby!
[/time-restrict-repeat]

A monthly schedule takes the following form:
[time-restrict-repeat type="monthly" ondate="01" offdate="07"]
The first week of the month
[/time-restrict-repeat]

You can both cross over the end of the month, and apply times to your start and end dates, e.g.
[time-restrict-repeat type="monthly" ondate="25" offdate="05" ontime="17:00:00" offtime="08:00:00"]
We are exceptionally busy at the end of each billing cycle. Please bear with us!
[/time-restrict-repeat]

And lastly, an annual schedule takes the following form:
[time-restrict-repeat type="annually" onmonth="June" offmonth="August" ondate="01" offdate="31"]
I'm currently in the mountains enjoying the summer!
[/time-restrict-repeat]

You can cross over the end of the month or even the end of the year, and apply times to your start and end dates, e.g.
[time-restrict-repeat type="annually" onmonth="December" ondate="24" offmonth="January" offdate="05" ontime="17:00:00" offtime="08:00:00"]
Our employees are currently enjoying time with their families for Christmas. We'll be back after the New Year.
[/time-restrict-repeat]

If you’re feeling creative, you can even nest shortcodes to account for multiple concurrent conditions. Since you cannot nest shortcodes with the same name, you need to add -2 or -3 to time-restrict-repeat in your shortcode (e.g. [time-restrict-repeat-2]).
For example, showing a message during business hours only on Monday to Friday:
[time-restrict-repeat type="daily" ontime="08:00:00" offtime="17:00:00"]
[time-restrict-repeat-2 type="weekly" onday="Monday" offday="Friday"]
Our store is currently open
[/time-restrict-repeat-2]
[/time-restrict-repeat]

You can also define a message which should appear if your content is not showing by using the else attribute @since 2.5. For example, you could invite people to visit your store during opening hours and ask them come back soon otherwise, like this:
[time-restrict-repeat type="daily" ontime="08:00:00" offtime="17:00:00" else="We're currently closed. Come back and see us when we're open."]
[time-restrict-repeat-2 type="weekly" onday="Monday" offday="Friday" else="We're currently closed. Come back and see us when we're open."]
Our store is currently open
[/time-restrict-repeat-2]
[/time-restrict-repeat]

Note that with nested shortcodes, you need to add the else attribute to each shortcode.
Things to bear in mind

The time used by the plugin is your site’s local time (check in Settings > General).
The else attribute does accept HTML, but is restricted by WordPress’ limitation on HTML inside shortcode attributes.

I also run Do It With WordPress, which has an array of tutorials for managing, modifying and maintaining your WordPress sites, as well as The WP Butler, a service for keeping your site maintained, backed up, updated and secure.

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Show/Hide Content at Set Time」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.0 | 2.0 | 2.1 | 2.2 | 2.3 | 2.4 | 2.5 | 1.0.1 | 1.0.2 | 2.1.1 | 2.3.1 | trunk |

延伸相關外掛(你可能也想知道)

  • Expire Users 》, 重要的安全更新–如果您正在使用版本0.2或更早的版本,請進行升級, , 此外掛允許您為用戶登錄設置到期日期。 您可以設置用戶為:, , 永不到期(默認值), 在...。
  • WP Post Expires 》這是一個簡單的外掛程式,可讓您設定文章的某個日期,此日期之後將執行三種操作之一:「為標題新增前綴」、「移到草稿」、「移到垃圾桶」。, 功能:, , 設定...。
  • Expire Sticky Posts 》這是一個簡單的外掛程式,可讓您在文章上設定到期日期。一旦文章過期,它將不再固定在頂部。, 如果您發現漏洞或有建議或改進要提交,此外掛程式可在Github上...。
  • WooCommerce Cart Stock Reducer 》WooCommerce不會將物品從庫存中移除,直到有人實際購買該物品。, 這個外掛可以減少物品的“虛擬”庫存數量,而不必實際修改物品, 庫存,因此如果購物車數據不小...。
  • VA Simple Expires 》VA Simple Expires 是一個 WordPress 外掛,可以讓你為文章添加過期日期。, 使用方法非常簡單,你只需為文章指定一個過期日期,當日期到達後,該文章便會從你...。
  • Auto Prune Posts 》這個外掛可以依據設定的時間,自動刪除已過期的文章或頁面,並且可以針對特定類別(一個類別或全部類別)執行此動作。, 如果您想要讓文章擁有有限的時間性,...。
  • Expiring Posts 》該外掛可在指定日期後設置文章過期並失效。, 該外掛目前僅適用於傳統編輯器。, 它通過在發布方塊中添加一個新的“失效日期”字段來實現此功能。, 默認情況下,...。
  • Simple Post Expiration 》這是一個簡單的外掛程式,允許您為文章設置到期日期。一旦文章到期,「已過期」將出現在文章標題前綴。, 您可以使用 [expires] 短代碼來顯示文章的到期狀態。...。
  • Simple Expires 》啟用該外掛後,您可以設定文章或頁面在特定時間到達後自動過期或更改,並提供過期通知。, 通知選項, 簡單期限也可以提醒您:, , 當過期時, , 這個提醒可以幫助...。
  • Content Scheduler 》Content Scheduler 讓您控制內容何時自動到期,到期時要做什麼以及是否要通知網站貢獻者內容已過期。, 到期選項, 您可以控制到期時發生的事情,包括:, , 更...。
  • Password Protection Expiration 》當你在 WordPress 中對一篇文章進行密碼保護時,會設定一個有效期為10天的 cookie,讓使用者在這10天內不需要再次輸入密碼。此外掛讓您輕鬆調整此 cookie 的...。
  • Auto Post Expire 》### 摘要, - 這個外掛允許您自動為您的文章設置到期日期,確保它們隨著時間的推移得到有效管理。, - 當文章達到到期日期時,它會自動移動到草稿狀態,在前端...。
  • NEW! WordPress Status Monitor 》WordPress Status Monitor 是一個易於安裝的管理外掛,用於檢查您的網站的狀態、資源和正常運作的時間。, 特點, , 狀態監控:測試您的網站是否運作正常以及其...。
  • Media Expirator 》Media Expirator 外掛讓使用者可以設定媒體庫項目的過期日期,當日期到達後,檔案將自動從媒體庫中刪除。, 使用者可以直接在媒體編輯器中啟用/停用每個媒體項...。
  • Expire posts 》此外掛已不再進行開發或支援。這個外掛僅作為一個過去曾經運作的證明,並且對於其他解決方案是一個良好的起點。, 使用方法:, 安裝完成後,前往您的儀表板中...。

文章
Filter
Apply Filters
Mastodon