[WordPress] 外掛分享: Administrative Shortcodes

首頁外掛目錄 › Administrative Shortcodes
10+
安裝啟用
尚無評分
1756 天前
最後更新
問題解決
WordPress 3.1+ v0.3.4 上架:2016-04-05

內容簡介

Administrative Shortcodes 提供一組專為網站管理者設計的短代碼,可依條件判斷顯示內容、排程發佈、載入模板、顯示自訂欄位等,大幅提升內容管理的彈性與效率。

【主要功能】
• 條件式內容顯示,支援 WordPress 所有條件標籤
• 排程短代碼,指定日期後才顯示內容
• 載入佈景主題模板檔案
• 顯示文章自訂欄位值
• 多站網路中跨站台執行短代碼
• 取得網址參數與表單變數

外掛標籤

開發者團隊

⬇ 下載最新版 (v0.3.4) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Administrative Shortcodes」→ 直接安裝(推薦)

原文外掛簡介

A set of shortcodes for the website administrators.
if
Using this shortcode you can limit the display of the text or shortcodes to specific page(s) on your website. You can use all the conditional tags WordPress provides. Checkout examples below.
Show text only on the homepage:
[if is_front_page] The text [/if]

Show text only on the About page of the site:
[if is_page="about"] The text [/if]

Show only on the category archive view:
[if is_category] The text [/if]

You can add “not_” before the conditional tag to reverse the logic, example:
Show on all pages of the site except the homepage:
[if not_is_front_page] The text [/if]

Using multiple parameters, the content is displayed when either of the conditions are met (“OR” comparison), for example, show text on both category and tag archive pages:
[if is_category is_tag] The text [/if]

To set multiple conditions you can nest the shortcode, for example show text only on homepage AND if the user is logged in:
[if is_user_logged_in][if is_front_page] The text [/if][/if]

Show a link to wordpress.org site, only on single post pages and only on mobile devices:
[if wp_is_mobile][if is_single] WordPress [/if][/if]

switch_to_blog
Run shortcodes in the context of another website in the network. This shortcode is only available in multisite installations (WP Network). For example, list posts from another blog:
[switch_to_blog id="10"] [list_posts limit="10"] [/switch_to_blog]

iterator
Display text or shortcodes only if repeated a certain number of times. Requires an “id” parameter which should be unique for that shortcode (can be anything you want).
[iterator id="my-ads" repeat="5"] My ad codes [/iterator]

After every 5th call to that shortcode, render the output.
get_template
Load a template file into the page. The referenced file is loaded from child theme if it exists, if not from the parent theme. Example, load includes/slider.php template file from the theme:
[get_template slug="includes/slider"]

scheduler
Show text or shortcodes only if the specified date has passed. Example, show the text only if it’s after Christmas of 2016:
[scheduler date="December 25, 2016"] Text [/scheduler]

date
Shows the current date or time in the specified format (https://codex.wordpress.org/Formatting_Date_and_Time). Uses Date Format (in Settings > General) by default.
[date format="F j, Y"]

loginoutlink
Display a link to login page if user is not logged-in, or a logout page if they are. Parameters:

login : “Log in” text
logout : “Log out” text
redirect : optional URL to redirect to on login or logout

login_form
Display the login form.
custom_field
Display a custom field from a post. Parameters:

key : name of the custom field to show. This parameter is required.
post_id : the ID of the post to display the custom field from; by default uses the current post in the loop
before : show a text to display before the value of the field
after : show a text after the value of the field

disable
Wrap any content or shortcode with [disable] shortcode to prevent that piece of content from being rendered. Perfect for debugging shortcodes.
the_id
Shows the current post ID; useful when you need to debug WP Loops.
Path shortcodes
[home_url] : returns the homepage URL
[get_template_directory] : Absolute path to the parent theme directory
[get_template_directory_uri] : URL to the directory of the parent theme
[get_stylesheet_directory] : Absolute path to the directory of the child theme
[get_stylesheet_directory_uri] : URL to the directory of the child theme
rand shortcodes
Show a random number between two numbers. Parameters:
* min : minimum value (default 0)
* max : maximum value (default 100)
get_var
Retrieve a value from $_GET or $_POST variables.
To get a URL query string:
[get_var get="myvar"]

To get a value from POST:
[get_var post="myvar"]

延伸相關外掛

文章
Filter
Apply Filters
Mastodon