[WordPress] 外掛分享: Post Content Shortcodes

WordPress 外掛 Post Content Shortcodes 的封面圖片。

內容目錄

前言介紹

  • 這款 WordPress 外掛「Post Content Shortcodes」是 2011-08-29 上架。
  • 目前有 3000 個安裝啟用數。
  • 上一次更新是 2018-04-03,距離現在已有 2588 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 4.3 以上版本才可以安裝。
  • 有 31 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

cgrymala |

外掛標籤

clone | post list | shortcode | syndication | post content |

內容簡介

這個外掛新增了兩個短碼,允許您在文章內容區域中顯示文章的內容或文章列表。此外掛應該能夠完全兼容所有文章類型,因為它只是使用 WordPress 函數 get_post() 和 get_posts()。

文章內容

第一個短碼是 [post-content] 短碼。使用此短碼,您可以在另一篇文章中顯示一篇文章的內容。這個短碼需要一個帶有鍵值 "id" 的屬性。例如,若要顯示 ID 為 25 的文章或頁面的內容,您可以像這樣使用此短碼: [post-content id=25]。此短碼還接受以下可選參數:

post_name => null - 您想要提取的文章的 slug。這可以代替 id 屬性使用
show_image => false - 確定是否顯示特色圖像(如果是,則會出現在內容之前)
show_excerpt => false - 確定是否預設顯示文章摘要而不是文章內容(如果未設置摘要,仍會回退到文章內容)
excerpt_length => 0 - 如果您想限制頁面上顯示的內容/摘要長度,請指定應該顯示的最大單字數(超出此限制的任何文章都會自動添加 "閱讀更多" 鏈接)。
image_width => 0 - 特色圖像應該調整的寬度(以像素為單位)
image_height => 0 - 特色圖像應該調整的高度(以像素為單位)
show_title => false - 是否在內容頂部顯示文章標題。預設情況下,標題會被包在

標籤中,但您可以使用 post-content-shortcodes-title 過濾器修改標題輸出。
link_image => false(如果您希望將特色圖像包裝成連結以連接到文章,則設置為 true / 1)- 在 0.6 版中添加
view_template => null(如果您使用 Views 外掛,您可以設置現有內容模板的 ID,以代替默認的列表項目輸出)- 在 0.6 版中添加
shortcodes => false - 預設情況下,此外掛會從文章內容/摘要中移除短碼。如果您希望嘗試處理/渲染內容中的短碼,請將此旗標設置為 true。

文章列表

第二個短碼是 [post-list] 短碼。此短碼不需要任何參數,但將接受以下參數(其中大多數是與 get_posts() 一起使用的預設參數):

numberposts => -1
offset => 0
category => null(可以接受帶引號的分類 slug 或沒有引號的分類 ID)
orderby => title
order => asc
include => null
exclude => null
meta_key => null
meta_value => null
post_type => 'post'
post_mime_type => null
post_parent => null
post_status => null

原文外掛簡介

This plugin adds two shortcodes that allow you to display either the content of a post or a list of posts within the content area of a post. This plugin should be fully compatible with all post types, as it simply uses the get_post() and get_posts() WordPress functions.
Post Content
The first shortcode is the [post-content] shortcode. Using that shortcode will allow you to display the content of one post within another post. This shortcode requires a single attribute with a key of “id”. To use this shortcode to display the content of a post or page with an ID of 25, you would use this shortcode like [post-content id=25]. This shortcode also accepts the following optional arguments:

post_name => null – The slug of the post that you want to pull. This can be used in place of the id attribute
show_image => false – Determines whether or not to display the featured image (if so, this appears before the content)
show_excerpt => false – Determines whether to default to showing the post excerpt instead of the post content (still falls back to post content if the excerpt is not set)
excerpt_length => 0 – If you would like to limit the length of the content/excerpt shown on the page, specify the maximum number of words that should be shown (a read more link will automatically be appended to any entries that exceed that limit).
image_width => 0 – The width, in pixels, to which the featured image should be sized
image_height => 0 – The height, in pixels, to which the featured image should be sized
show_title => false – Whether or not to show the post title at the top of the content. By default, the title is wrapped in

tags, but you can use the post-content-shortcodes-title filter to modify the title output.
link_image => false (set this to true/1 if you would like to wrap the featured image in a link to the post) – Added in 0.6
view_template => null (if you are using the Views plugin, you can set the ID of an existing Content Template to be used in-place of the default list item output) – Added in 0.6
shortcodes => false – By default, this plugin strips shortcodes out of the post content/excerpt. If you would like to attempt to process/render shortcodes in the content, set this flag to true.

Post List
The second shortcode is the [post-list] shortcode. This shortcode does not require any arguments, but will accept the following arguments (most of which are the default arguments used with get_posts()):

numberposts => -1
offset => 0
category => null (can accept category slug [with quotes] or category ID [without quotes])
orderby => title
order => asc
include => null
exclude => null
meta_key => null
meta_value => null
post_type => 'post'
post_mime_type => null
post_parent => null
post_status => 'publish'
exclude_current => true
–blog_id => 0 (the numeric ID of the site from which to pull the posts)–
blog => null (can be set to the numeric ID or the blog name [slug] of the site from which to pull the posts – this replaces the old blog_id attribute)
show_image => false
show_excerpt => false
excerpt_length => 0
image_width => 0
image_height => 0
tax_name => null (the name of a taxonomy – e.g. “tag”, “category”, etc. – to be used to filter the list of posts) – Added in 0.6
tax_term => null (the list of term IDs or slugs to filter the list of posts – multiple IDs or slugs can be separated by spaces) – Added in 0.6
link_image => false (set this to true/1 if you would like to wrap the featured image in a link to the post) – Added in 0.6
ignore_protected => false (set this to true/1 if you would like the post list to exclude any password-protected posts) – Added in 0.6
view_template => null (if you are using the Views plugin, you can set the ID of an existing Content Template to be used in-place of the default list item output) – Added in 0.6

The first 13 arguments are standard arguments for the get_posts() function.
The exclude_current argument is not a standard argument for the get_posts() function. It is a custom argument for this plugin. When that argument is set to true, the current page or post will be excluded from the list of posts. If it is set to false, "false" or 0, the current page or post will be included in the post list.
The blog_id argument is also not standard. That argument allows you to pull a post from a site other than the current site when using WordPress multisite. Simply set that argument to the ID of the site from which you want to pull the post, and the post with the id you specify will be pulled from the blog/site with the blog_id you specify.
The show_image, image_width and image_height arguments only apply to the post-list shortcode. They determine whether to display the featured image and how to display it for each post within the list. If the image_width and image_height arguments are both set to 0 (which is the default), the “thumbnail” size will be used (assuming the show_image argument is set to 1 or “true”). If only one of the image_width or image_height arguments are set, the other argument will be set to 999999 to ensure that the specified dimension is met.
The show_excerpt and excerpt_length arguments also apply to the post-list shortcode. If you set show_excerpt to 1 or “true”, the post excerpt will be shown if it exists. If it doesn’t exist (or is empty), the post content will be shown (with HTML stripped out of it). You can truncate the length of the excerpts that are shown in the post list by setting the excerpt_length value. The excerpt_length is measured in words, so if you would like each excerpt to display no more than 50 words, you would set the excerpt_length parameter to 50. If you leave it set to 0 (which is the default), the entire excerpt or content will be shown in the post list. In the post-list shortcode, if show_excerpt is set to 0 or false, no content will be shown in the list (as opposed to the behavior of the show_excerpt parameter in the post-content shortcode).
The view_template argument can be a bit complicated to get working properly, and is still a bit experimental. Please use it at your own risk. Unfortunately, the standard [wpv-post-featured-image] and [wpv-post-url] shortcodes (and, by extension, the [wpv-post-link] shortcode) do not work properly, especially when trying to display content from another site in the network. There are three extra shortcodes created for use in your Content Template, the first two of which replace the [wpv-post-featured-image] and [wpv-post-url] shortcodes:

[pcs-thumbnail] – will output the post thumbnail (at the width/height you set in the post-content/post-list shortcode attributes)
[pcs-post-url] – will return/output the URL to the post
[pcs-entry-classes] – will add some additional classes to the entry wrapper. Accepts 2 parameters:

classes – a space-separated list of the CSS classes you want to apply to the entry
columns – a numerical value representing how many columns you want in the list (which will automatically add column-1, column-2, etc. to the list of entry classes, as well as adding a class of “first” to the first item in each row – for instance, if you have 6 items, and you use [pcs-entry-classes classes="foo bar entry" columns="3"], the class list for the first and fourth items will be foo bar entry column-1 first, the class list for the second and fifth items will be foo bar entry column-2 and the class list for the third and sixth items will be foo bar entry column-3)

I have created a Gist showing a simple example of a Views Content Template used with a Post List widget.
To read more about the other arguments, please visit the codex page for the get_posts() function.
If you are looking to display a list of attachments in a post, rather than displaying a list of posts or pages, you might want to check out the List Attachments Shortcode plugin instead.
Multisite – Pulling Posts From Another Blog
To pull a list of posts from another blog, simply provide the blog’s ID as the blog_id argument in the shortcode. With that argument, this plugin will pull a list of posts that match the other criteria you provided. If the blog_id argument is provided, and the blog_id doesn’t match the ID of the current blog, the exclude_current argument will be ignored (otherwise, this plugin would automatically exclude whatever post on the other blog happens to have the same ID as the current post).
When the list is displayed, shortlinks (that blog’s URL with ?p=[post_id]) will be used, rather than the proper permalink, since it would require a lot more resources to build the proper permalink.
The usage would look something like:
[post-list blog_id=12 post_type="page"]

When displaying a post list, you can use any post_type that is registered on that blog (that post_type does not have to be registered on the current site).
To display the content of a single post from another blog, again, simply provide the blog’s ID as the blog_id argument. That will pull the content of that post. Unfortunately, at this time, there is no way to invoke all of the plugins from the blog from which you’re pulling the content, so any shortcodes, filters, etc. that may be active on the source blog will not be parsed when the content is displayed on the current blog. Obviously, if all of the same plugins and themes are active (or, if any plugins/themes that introduce shortcodes and filters are active) on both the source blog and the current blog, then there is nothing to worry about.
The usage would look something like:
[post-content blog_id=12 id=25]

That would pull the content for the post with an ID of 25 from the blog with an ID of 12.
To Do

Add AJAX features to allow user to choose from a list of posts/sites, instead of requiring them to manually enter the ID

各版本下載點

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

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


0.2 | 0.3 | 0.4 | 0.5 | 1.0 | 0.1a | 0.3.1 | 0.3.2 | 0.3.3 | 0.3.4 | 0.4.1 | 0.5.5 | 0.5.6 | 1.0.1 | trunk | 0.3.2.1 | 0.3.2.2 | 0.3.4.1 | 1.0.1.1 |

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

  • FeedWordPress 》, 作者:C. Johnson, 項目網址:http://feedwordpress.radgeek.com/, 授權:遵循 GPL 2 進行授權。有關版權信息的詳細說明請參閱下文的授權。, , FeedWordPre...。
  • Broadcast 》輕鬆進行網站內容的網絡同步傳播!, 現在,在 WordPress 多站點網絡中,只需一個源頭,即可輕鬆地進行內容同步傳播!您可以將文章同步傳播到網絡中的其他博客...。
  • Share on Mastodon 》這款外掛可以自動在Mastodon上分享 WordPress 文章。, 你可以選擇要分享哪種文章類型,但每篇文章仍然可以隨時停用分享功能。, 支援圖片上傳、WordPress 的新...。
  • The Tribal Plugin 》Tech Tribe 外掛讓 Tech Tribe 的會員可以自動從其會員資格中包含的月度營銷包中發佈部落格內容到其網站。, 該外掛允許會員:, , 設置他們想要作為所有文章默...。
  • Naver webmaster syndication v2 》這是一個與 NAVER 網站管理員工具和 Syndication v2 整合的外掛程式。, , , 透過 NAVER Syndication 整合,可以快速在 NAVER 搜尋結果中展示網站網頁。, , , ...。
  • WP Pipes 》ss and use them as input., , AVAILABLE DESTINATIONS (more will come up later):, , Post: to save data to WordPress Posts., RSS Feed: to generate RSS...。
  • Nordot: Content Curation & Syndication for WordPress 》WordPress內容整合與分發外掛, 使用 Nordot 的WordPress內容整合與分發外掛,快速、輕鬆地免費滿足您的編輯與發行需求。, 此外掛可以讓您:, 作為內容整理者...。
  • Syndication Links 》此外掛支援在 WordPress 的文章、頁面、和評論中加入 rel-syndication/u-syndication 連結,指示聯合發佈的複本在哪裡,並以文字或圖示連結的形式呈現。您可...。
  • Syndicate Out 》Syndicate Out能夠即時地將指定的分類下(或是所有的文章,依個人喜好)的全部文章轉發到另一個或多個WordPress的博客中。, 這樣一來,博客所有者不必再依賴R...。
  • FeedWordPress Advanced Filters 》, 作者: Bas Schuiling, 專案網址: http://www.weblogmechanic.com/plugins/feedwordpress-advanced-filters/, 授權: GPL 2. 版權細節請見下方, , FeedWordPr...。
  • Naver Syndication V2 》這是一個對應於 Naver Syndication API V2 的 WordPress 外掛。, 每當有文章被創建、修改、移入垃圾桶或從垃圾桶中恢復時,該外掛會發送包含文章地址的 ping ...。
  • Subscribe-Remind 》使用 Subscribe-Remind 外掛,每篇文章的末尾都會自動顯示一些文字,讓讀者可以訂閱你的 RSS 資訊或追蹤你的 Twitter 帳號。這是一種不會打擾讀者的有效方法...。
  • RESTful Content Syndication 》RESTful Syndication 可讓您使用 WordPress REST API 從其他 WordPress 網站自動處理內容。, 這可以讓您運行一個網站網路,讓所有網站都可以接收相同的文章內...。
  • WP Filter & Combine RSS Feeds 》針對英語使用者, WP Filter & Combine RSS Feeds在多語言和多站點上均有效, WP Filter&Combine RSS Feeds可以讓您查看一個或多個RSS源的所有發布內容,...。
  • Copy Post 》iPressGo Copy Post 可以讓您把任何已啟用 REST API 的 WordPress 博客文章,複製到您自己的 WordPress 博客中,並發布成草稿或已發布文章。此外,您可以創建...。

文章
Filter
Mastodon