[WordPress] 外掛分享: Get Post

首頁外掛目錄 › Get Post
100+
安裝啟用
尚無評分
5401 天前
最後更新
問題解決
WordPress 3.0+ v2.0.0 上架:2008-11-24

內容簡介

Get Post 是一個外掛,它新增了一個標籤,可讓您檢索並顯示最新的文章,這些文章由特定一組參數所識別。

當此外掛啟用後,在任何文章或頁面中,都可以使用以下格式的 get-post 標記:

[get-post tag=some-tag]

這將被替換為標記為給定標記的最新文章。

參數

這些參數控制著 get-post 擷取的文章。可以使用選項結合使用以建立一個標準擷取文章或文章列表的標準。
通過混合不同的標準,您可以對由外掛找到的文章進行高度控制。

[get-post tag=some-tag random show=3]

關於 WordPress 的一般注意事項:如果您指定 WordPress 找不到的標準,它會自己編制。例如,如果您指定不存在的標籤或分類,它將僅檢索最新的文章,而沒有任何指示出現錯誤的狀況。請務必確認您指定的選項是否符合您的意圖。

其中一些參數在指定時最好使用 slug。例如,在指定標籤時,最好使用 slug 值,而不是完整的標籤名稱。要找到 slug,請參閱管理面板 -> 文章 -> 文章標籤。slug 就列在該頁面的右側。

您可能希望使用帶有空格的選項值。這可以通過引號實現:

[get-post option="a value with spaces"]

tag(標籤):
指定要搜尋的標籤。應指定標籤的 slug。

[get-post tag=some-tag]

category(分類):
指定要搜尋的分類。應指定分類的 slug。

[get-post category=some-category]

show(顯示):
指定要顯示的文章數量。

[get-post show=5]

template(模板):
指定要使用的模板。此指定將覆蓋管理介面的選項中設置的模板。有關模板標記的更多詳細信息,請參閱模板部分。注意:如果輸入任何 HTML,請確認選擇了 HTML 編輯器而不是可視化編輯器。

[get-post template="<h1>Title: {title}</h1>"]

random(隨機):
從符合標準的文章中選擇一篇隨機文章。

[get-post random]

default(默認):
這並不是一個實際的選項。預設情況下,get-post 會顯示最新的部落格文章。

[get-post]

模板

Get-post 附帶了一個預設模板,可在大多數佈景主題中適當呈現常見的文章詳情。您可以自定義此模板,以添加或刪除包含的文章資料。此外,您可以使用 [get-post] 標記的 template 參數來指定一個一次性的模板。

當使用 show 參數擷取多篇文章時,此時模板將重複顯示每個擷取的文章。

這些標籤將根據擷取的文章的值進行替換。例如,包含 {title} 的模板將實際上有擷取文章的標題,而不是單詞 title。

外掛標籤

開發者團隊

⬇ 下載最新版 (v2.0.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Get Post」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Get Post adds a tag that allows you to retrieve and display the latest post
identified by a specific set of parameters.
When this plugin is active, any post or page can contain the get-post markup
as follows:
[get-post tag=some-tag]

This will be replaced with the latest post tagged with the given tag.
Parameters
The parameters control which posts are retrieved by get-post. Options can be
used in combination to build a list of criteria for post or posts to retrieve.
By mixing criteria, you can exert a lot of control over the post(s) which are
found by the plugin.
[get-post tag=some-tag random show=3]

One note on WordPress in general: if you specify criteria that WordPress can’t
match, it will make something up. For instance, if you specify a tag or
category that doesn’t exist, it will simply retrieve the latest post with no
indication that anything is wrong. Take care to ensure that the options you
specify are what you intend.
Several of these parameters work best when specifying the slugs. For instance,
when specifying a tag it’s best to use the slug value rather than the full
name of the tag. To find the slug, see the admin panel -> posts -> post tags.
The slug is listed right on that page.
You may wish to specify an option value with a space in it. This is
accomplished with quotes:
[get-post option="a value with spaces"]

tag:
Specify a tag to search for. The tag’s slug should be specified.
[get-post tag=some-tag]

category:
Specify a category to search for. The category’s slug should be specified.
[get-post category=some-category]

show:
Specify the number of posts to show.
[get-post show=5]

template:
Specify the template to use. This specification overrides the template set in
the options panel of the admin interface. See the template section for more
details on template tags. NOTE: If entering any HTML into this, please be
sure to select the HTML editor rather than the visual editor.
[get-post template="

Title: {title}

"]

random:
Select a random post from the matching criteria
[get-post random]

default:
This isn’t really an option. By default, get-post displays the latest blog
post.
[get-post]

Templates
Get-post ships with a default template that should render the usual post
details in a form that fits well with most themes. You can customize this
template to add or remove data from the included post. Additionally, you can
use the template parameter to the [get-post] tag to specify a one-off
template.
Using the show parameter will retrieve multiple posts. In this case, the
template will be repeated one time for each retrieved post.
These tags are replaced with the value from the retrieved post. For instance,
a template containing {title} will actually have the title of the retrieved
post, rather than the word title.

{title}:
The title of the post.

{content}:
The content of the post.

{author}:
The author of the post.

{date}:
The date the post was written.

{time}:
The time the post was written.

{permalink}:
A link to the post itself.

{authorlink}:
A link to all posts by the post’s author.

{id}:
The post’s ID number.

Examples
Indicate when your blog was last updated:
Blog last updated [get-post template="{date} at {time}."]

Link to the latest post:
Check out my post: [get-post template="{title}"]

How it works
This plugin does something a little bit unorthodox: It reenters “The
Loop” while the post content is being rendered. Then, it calls
whatever WordPress internal functions will safely work, using raw data from
$post when these functions are unsafe to call again. People curious about the
internals should examine class-get-post-getter.php. The class is structured
to be reusable by any other GPL2 projects.

延伸相關外掛

文章
Filter
Mastodon