[WordPress] 外掛分享: Archivist – Custom Archive Templates

首頁外掛目錄 › Archivist – Custom Archive Templates
WordPress 外掛 Archivist – Custom Archive Templates 的封面圖片
⚠ 此外掛已下架 — 不再更新維護,建議勿安裝。
1,000+
安裝啟用
★★★★
4.7/5 分(10 則評價)
748 天前
最後更新
問題解決
WordPress 3.0+ v1.7.7 上架:2011-09-14

內容簡介

快速入門

此外掛程式假設您的文章已經有良好的分類。
使用快捷碼在頁面或文章的任何位置顯示存檔。

[archivist category="kitten"]
[archivist tag="kitten"]

將 “kitten” 替換為您的分類/標籤。請注意,需要使用分類/標籤的 slug。(即名稱去掉大寫字母和空格)

佔位符

您可以指定自訂模板以顯示存檔元素。
前往 設定 > Archivist 取得外掛程式首選設定。
使用 HTML 及下列的模板佔位符號。

%TITLE% – 文章標題。
%PERMALINK% – 文章永久連結。
%AUTHOR% – 文章作者。
%CATEGORIES% – 文章分類,以項目清單(unordered list)的方式呈現。
%CATEGORIES|...% – 文章分類,使用自定義分隔符。例如: %CATEGORIES|, %
%TAGS% – 文章標籤,預設使用分隔符。
%TAGS|...% – 文章標籤,使用自定義分隔符。例如: %TAGS|, %
%EXCERPT% – 文章摘要。
%POST_META|...% – 文章中的任何文章 meta 資料。例如: %POST_META|duration%。
%POST_META|...|...% – 使用自定義 HTML 分隔符號呈現文章中的任何文章 meta 資料清單。例如: %POST_META|guest|<br>%
%DATE% – 以預設格式呈現文章日期。
%DATE|...% – 以自定義格式呈現文章日期。例如: %DATE|Y/m/d%
%POST_THUMBNAIL|...x...% – 以特定尺寸呈現文章縮圖。例如: %POST_THUMBNAIL|75x75%
%COMMENTS% – 文章評論數量。
%ACF|field_name% – 顯示 ACF 套件 包含的欄位。使用 get_field() 函式。

您可以新增您自己的佔位符:

add_filter( 'archivist_template_render', function( $template, $post ) {
// modify $template
return $template;
}, 10, 2 );

分頁

如果您有很多文章,您可能會想要分頁。Archivist 外掛程式內建異步分頁功能。在快捷碼中使用 pagination 參數啟用它。參數設定是每頁要顯示的文章篇數。

[archivist category="kitten" pagination="10"]

分頁控制會顯示在存檔的頂部和底部。您可以通過將 controls 設置為 top 或 bottom 進行自定義。

[archivist category="kitten" pagination="10" controls="top"]

依據查詢篩選

您感到有挑戰性?分類或存檔中的篩選還不足以滿足您?繼續閱讀,挑戰英文文檔:
WordPress 使用某些查詢語法定義所謂的迴圈 (loop),以顯示存檔。
您可以在 https://codex.wordpress.org/Class_Reference/WP_Query 上查看完整文檔。
您可以利用列在文檔中的每個參數或參數組合。以下是一些示例:

[archivist query="year=1984&author_name=gorwell"]

列出所有 1984 年由使用者 NICENAME 為 gorwell 的作者撰寫的文章。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.7.7) 或搜尋安裝

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

原文外掛簡介

Quick Start
The plugin assumes your articles are well categorized.
To display the archive, use the shortcode anywhere in a page or article.
[archivist category="kitten"]
[archivist tag="kitten"]

Replace “kitten” with your category/tag. Watch out, we need the slug here.
That’s the name without capital letters and spaces.
Placeholders
You can specify a custom template to display the archive elements.
Go to Settings > Archivist for plugin preferences.
Use HTML and any of the following template placeholders.

%TITLE% – The post title.
%PERMALINK% – The post permalink.
%AUTHOR% – The post author.
%CATEGORIES% – The post categories as unordered list.
%CATEGORIES|...% – The post categories with a custom separator. Example: %CATEGORIES|, %
%TAGS% – The post tags with default separator.
%TAGS|...% – The post tags with a custom separator. Example: %TAGS|, %
%EXCERPT% – The post excerpt.
%POST_META|...% – Any post meta. Example: %POST_META|duration%.
%POST_META|...|...% – Any post meta list, separated by custom HTML. Example: %POST_META|guest|
%
%DATE% – The post date with default format.
%DATE|...% – The post date with custom format. Example: %DATE|Y/m/d%
%POST_THUMBNAIL|...x...% – The post thumbnail with certain dimensions. Example: %POST_THUMBNAIL|75x75%
%COMMENTS% – The post comment count.
%ACF|field_name% – Display ACF field. Uses the get_field() function.

You can add your own placeholders:
add_filter( 'archivist_template_render', function( $template, $post ) {
// modify $template
return $template;
}, 10, 2 );

Pagination
If you have many entries, you may prefer to paginate. The archivist comes with asynchronous pagination built-in. Use the pagination parameter in the shortcode to activate it. Its value is the amount of items you want to display per page.
[archivist category="kitten" pagination="10"]

Pagination controls are displayed both on top and at the bottom of the archive. You can customize this by setting controls to top or bottom.
[archivist category="kitten" pagination="10" controls="top"]

Filter by Query
Are you feeling bold? Is filtering by category or archive not satisfying you? Read on, I’ve got a challenge for you.
WordPress uses a certain query syntax to define the so called loop which is used to display the archive.
You can find the complete documentation at https://codex.wordpress.org/Class_Reference/WP_Query
and you can take advantage of every single parameter or combination of parameters listed there. Some examples:
[archivist query="year=1984&author_name=gorwell"]

Lists all entries from the year 1984 by the author with user_nicename gorwell.
[archivist query="tag=straw+mask&post_status=private&orderby=comment_count&order=DESC"]

Lists all entries marked with post status private which are tagged with both straw and mask, ordered by the amount of comments in a descending order.
Using multiple Templates
When you install the plugin, there is just one templated called “default”.
If you don’t specify a specific template in the shortcode, this one will be used.
Therefore the following two shortcodes yield identical results.
[archivist category="kitten"]
[archivist category="kitten" template="default"]

You can add as many templates as you like. Think twice before deleting one. If it’s still in use, the archive can’t be displayed.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon