[WordPress] 外掛分享: Get Post Content Shortcode

WordPress 外掛 Get Post Content Shortcode 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Get Post Content Shortcode」是 2014-05-19 上架。 目前已經下架不再更新,不建議安裝使用。
  • 目前有 100 個安裝啟用數。
  • 上一次更新是 2016-04-20,距離現在已有 3301 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.6.0 以上版本才可以安裝。
  • 有 7 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

webdeveric |

外掛標籤

shortcode | post content |

內容簡介

這個外掛提供一個短碼(shortcode)以ID編號取得文章內容。
預設情況下,內容會經過wpautop()和do_shortcode()處理,除非你使用下方顯示的屬性或過濾器來控制。

範例
[post-content id="42"]

這個範例會取得編號為42的文章內容。

[post-content id="42" autop="false"]

這個範例會取得編號為42的文章內容,但不會進行 wpautop 處理。

[post-content id="42" shortcode="false"]

這個範例會取得編號為42的文章內容,但不會進行 do_shortcode 處理。

[post-content id="42" autop="false" shortcode="false"]

這個範例會取得編號為42的文章內容,但不會進行 wpautop 或 do_shortcode 處理。

[post-content id="42" status="publish,future"]

這個範例只會取得編號為42的文章,且狀態必須是「publish」或「future」。

[post-content id="42" field="excerpt"]

這個範例會取得編號為42的文章摘錄(excerpt)。

注意:
所包含的文章內容可能仍會進行 wpautop 處理。

屬性

id – 整數

文章 ID

autop – 布林值 – 預設: true

以下任何值都等於 true:true、1、yes。其他所有值都等於false。

shortcode – 布林值 – 預設: true

以下任何值都等於 true:true、1、yes。其他所有值都等於false。

status – 文字 – 預設: publish

任何預設或自訂的 WordPress 狀態值(publish、draft、future 等等)。

如果 WordPress 沒有註冊狀態,則會使用預設值。

field – 文字 – 預設: post_content

您想要擷取的資料庫欄位名稱。

如果欄位名稱不在允許的欄位名稱陣列中,則會使用此預設值。

過濾器

您可以使用此過濾器修改允許擷取的欄位。

add_filter('post-content-allowed-fields', function($allowed_fields) {
// 在這裡進行您的篩選。
return $allowed_fields;
});

您可以指定預設的 shortcode 屬性值。

add_filter('post-content-default-attributes', function ($default_attributes) {
// 在這裡輸入您的程式碼。
return $default_attributes;
});

您可以按短碼用途篩選屬性。

add_filter('shortcode_atts_post-content', function ($out, $pairs, $attributes) {
// 在這裡輸入您的程式碼。
return $out;
}, 10, 3);

原文外掛簡介

This plugin provides a shortcode to get the content of a post based on ID number.
By default, the content will be passed through wpautop() and do_shortcode() unless you tell it not to by using attributes or filters as shown below.
Examples
[post-content id="42"]

This gets the content of post 42.
[post-content id="42" autop="false"]

This gets the content of post 42 and does not call wpautop on the content.
[post-content id="42" shortcode="false"]

This gets the content of post 42 and does not call do_shortcode on the content.
[post-content id="42" autop="false" shortcode="false"]

This gets the content of post 42 and does not call wpautop or do_shortcode on the content.
[post-content id="42" status="publish,future"]

This gets the content of post 42 only if the post_status is “publish” or “future”.
[post-content id="42" field="excerpt"]

This gets the excerpt of post 42.
Note:
The containing post may still have wpautop called on it’s content.
Attributes

id – integer
The post ID

autop – boolean – default: true
The following values equal true: true, 1, yes. All other values equal false.

shortcode – boolean – default: true
The following values equal true: true, 1, yes. All other values equal false.

status – text – default: publish
Any default or custom WordPress status value (publish, draft, future, etc.).
The default value will be used if the status is not registered with WordPress.

field – text – default: post_content
The name of the database column you want to retrieve.
This default value will be used if the column name is not in the array of allowed field names.

Filters
You can modify the fields that are allowed to be retrieved with this filter.
add_filter('post-content-allowed-fields', function($allowed_fields) {
// Do your filtering here.
return $allowed_fields;
});

You can specify the default shortcode attribute values.
add_filter('post-content-default-attributes', function ($default_attributes) {
// Your code here.
return $default_attributes;
});

You can filter attributes per shortcode usage
add_filter('shortcode_atts_post-content', function ($out, $pairs, $attributes) {
// Your code here.
return $out;
}, 10, 3);

各版本下載點

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

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


0.2 | 0.3.0 | 0.3.1 | 0.3.2 | 0.4.0 | trunk |

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

  • WP Shortcodes Plugin — Shortcodes Ultimate 》Shortcodes Ultimate 是一個全面的視覺與功能性元素收集,您可以在文章編輯器、文字小工具甚至是範本檔案中使用。使用 Shortcodes Ultimate,您可以輕鬆地建...。
  • MW WP Form 》MW WP Form 可以使用 shortcode 創建帶有確認畫面的郵件表單。, , 使用 shortcode 創建表單, 可以使用確認頁面。, 頁面可以使用相同的 URL 或個別的 URL 進行...。
  • Shortcoder — Create Shortcodes for Anything 》Shortcoder 外掛可讓您建立 HTML、JavaScript、CSS 和其他代碼片段的自訂捷徑。現在,這些捷徑可以在文章/頁面中使用,並且該片段將取代其位置。, ✍ 輕鬆建立...。
  • Display Posts – Easy lists, grids, navigation, and more 》Display Posts 讓您輕鬆地列出網站上的所有內容。首先在內容編輯器中新增此短碼,以列出最近的文章清單:, [display-posts], , 按類別篩選, 若只想顯示特定類...。
  • Widget Shortcode 》這個短碼需要小工具的ID,但不需要猜測,外掛會為你生成代碼。如果你想要覆蓋小工具的標題,你可以使用 "title" 參數:, [widget id=”text-1″...。
  • Woody code snippets – Insert Header Footer Code, AdSense Ads 》需要專業的支援嗎?, 免費獲取支援, 開始獲得高級支援, , 停止反覆使用相同的內容!, 停止插入 function.php 中的 PHP 代碼!, 停止將 Google Analytics、Yan...。
  • Column Shortcodes 》此外掛提供簡單易用的短碼,在您的文章或頁面中輕鬆創建欄位。有時候,您只需要將網頁切成不同的欄位。使用此外掛,您只需選擇一個欄位的短碼,便可將欄位加...。
  • amr shortcode any widget 》使用shortcode將小工具或多個小工具或整個小工具區域(側邊欄)插入到頁面中。, 首先在正常的側邊欄中設置小工具。 檢查它是否正常運作。, 然後將所選小工具...。
  • Shortcode in Menus 》此外掛讓你可以在 WordPress 導覽選單中使用簡碼,以便可以動態生成連結。也可以讓你在導覽選單中添加完整的 HTML 段落。, 使用方法, 查看截圖。, 另外,查看...。
  • Sidebar Widgets by CodeLights 》❗ 很抱歉,由於 SiteOrigin 的 widgets API 完全更改,CodeLights 不再支援 SiteOrigin Page Builder 的原生使用。解決方案:您仍然可以在純文字編輯器中創...。
  • Advanced iFrame 》看起來您正在尋找一個 WordPress 外掛 - Advanced iFrame Pro。這個外掛可讓您使用 iframe 包含其他網頁到您的網站中,同時具有隱藏和修改元素、自動調整高度...。
  • Insert Pages 》Insert Pages 可讓您使用 Shortcode API,將任何 WordPress 內容(例如,頁面、文章、自訂文章類型)嵌入其他 WordPress 內容。它還包括一個小工具,可將頁面...。
  • Shortcodes by Angie Makes 》Shortcodes by Angie Makes 外掛為您的 WordPress 主題新增一系列易於使用的短碼,這些短碼與 Angie Makes WordPress 主題 完美搭配。, 範例, 請到此查看這些...。
  • Team Members 》這個外掛會為管理員面板增加一個「團隊」區塊,讓您可以輕鬆地在網站上展示您的員工/職員。您可以快速地將成員加入您的團隊,加入他們的照片、職位、個人簡介...。
  • Post Snippets – Custom WordPress Code Snippets Customizer 》, 建立自訂短碼和可重複使用的內容,並將它們插入到您的文章和頁面中。, , 此外掛讓您建立 HTML、PHP 程式碼或常用文字片段的庫。在文章和頁面中,您可以使用...。

文章
Filter
Apply Filters
Mastodon