[WordPress] 外掛分享: insert

首頁外掛目錄 › insert
10+
安裝啟用
尚無評分
4458 天前
最後更新
問題解決
WordPress 2.7.0+ v0.1.0 上架:2014-01-29

內容簡介

如何使用

在文章或任何處理 簡碼 的地方使用 [insert] 簡碼。

[insert] 簡碼屬性

query – 透過 get_posts() 建立一個新的 WP_Query
data – 傳遞給操作的數據
action – 要運行的操作,如果適用,將對每篇文章運行
filter – 要運行的篩選器,如果適用,將對每篇文章運行
template – 透過 locate_template() 載入的模板

所有屬性都是可選的,可以結合使用以獲得強大的功能。

功能

[insert] 可以實現的功能是非常多樣化的,包括:

在文章中插入其他文章
在文章中插入鉤子(hook)
在小工具中插入文章
透過小工具運行操作鉤子
透過小工具載入模板

範例
插入模板
`

[insert template=”branding.php”]
`

插入操作
`

[insert action=”dostuff”]
`

向操作傳遞數據
`

[insert data=”field=slug&value=example&tax=category” action=”dostuff”]
`

操作將數據作為數組接收。

`

add_action(‘dostuff’, ‘print_r’);
`

透過模板插入頁面
`

[insert query=”name=about&post_type=page” template=”entry.php”]
`

透過操作插入頁面

此操作設置查詢並啟動操作。

`

[insert query=”name=about&post_type=page” action=”dostuff”]
`

WP 模板標記在操作中可用。

`

add_action(‘dostuff’, ‘the_title’);
`

Github

github.com/ryanve/insert

外掛標籤

開發者團隊

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

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

原文外掛簡介

Usage
Use the [insert] shortcode inside posts or anywhere else that processes shortcodes.
[insert] shortcode attributes

query – sets up a new WP_Query via get_posts()
data – data to pass to actions
action – action to run, runs for each post if applicable
filter – filter to run, runs for each post if applicable
template – template to load via locate_template()

All attributes are optional and can be used in combination to yield powerful abilities.
Abilities
Possibilities with [insert] are endless. Practical uses include:

Insert posts into posts
Insert hooks into posts
Insert posts into widgets
Run action hooks via widgets
Load templates via widgets

Examples
Insert a template
`

[insert template=”branding.php”]
`
Insert an action
`

[insert action=”dostuff”]
`
Pass data to an action
`

[insert data=”field=slug&value=example&tax=category” action=”dostuff”]
`
The action receives data as an array.
`

add_action(‘dostuff’, ‘print_r’);
`
Insert a page via template
`

[insert query=”name=about&post_type=page” template=”entry.php”]
`
Insert a page via action
This sets up the query and triggers the action.
`

[insert query=”name=about&post_type=page” action=”dostuff”]
`
WP template tags are available inside the action.
`

add_action(‘dostuff’, ‘the_title’);
`
Github

github.com/ryanve/insert

延伸相關外掛

文章
Filter
Apply Filters
Mastodon