前言介紹
- 這款 WordPress 外掛「Post Type Archive Pages」是 2019-11-30 上架。
- 目前有 300 個安裝啟用數。
- 上一次更新是 2020-01-30,距離現在已有 1921 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 5.0 以上版本才可以安裝。
- 外掛要求網站主機運作至少需要 PHP 版本 5.6 以上。
- 有 1 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
內容簡介
Post Type Archive Pages 可讓您選擇在內容頁結構中的頁面,作為自訂文章類型的存檔頁面。這讓您控制存檔頁面的永久網址,並允許它們被嵌套在其他頁面下面。它還為該文章類型的單篇文章和詞彙存檔設定了永久鏈結基底。
安裝並啟用外掛後,您可以在「設定 > 閱讀」下,為每個已註冊的文章類型選擇存檔頁面。
模板
WordPress 將搜尋您設定為存檔頁面的頁面的存檔頁面模板。因此,會使用 archive-$posttype.php 和 archive.php 模板檔案,而不是 page.php。
此外,外掛的主要實例會返回一些可在構建主題時有用的函數。
取得存檔頁面
返回所提供的文章類型別名的存檔頁面的頁面物件。如果從文章類型存檔模板、單數模板或詞彙存檔中調用並且未提供別名,則會使用相關的文章類型。
例如:
$page = post_type_archive_pages()->get_archive_page('book');
取得存檔頁面文章類型
返回提供的頁面 ID 是其存檔頁面的文章類型物件。
例如:
$postType = post_type_archive_pages()->get_archive_page_post_type(5);
選單改進
將存檔頁面加入選單時,當查看文章類型存檔時,它們將被標記為當前選單項目,而當檢視該文章類型的文章時,它們將被標記為當前選單項目的父級 / 祖先。相關的 CSS 類別也將應用。
Advanced Custom Fields 改進
當與 Advanced Custom Fields 搭配使用時,此外掛尤其有效。它註冊了其他頁面型別位置規則,允許您向所有存檔頁面或特定文章類型的存檔頁面添加欄位。因此,如果您的列表頁需要像描述或頁首圖像這樣的內容,您可以將這些欄位放置在存檔頁面本身上。
要在您的存檔模板中訪問這些欄位,您只需調用:
$desc = get_field( 'description', post_type_archive_pages()->get_archive_page() );
開發人員掛鉤
此外掛嘗試設置最適合大多數情況的預設值。但是,如果需要,在某些地方可以加入掛鉤並更改這些預設值。
過濾器 - post_type_archive_pages/supported_post_types
默認情況下,您可以為除了內置頁面和文章之外的任何其他公開文章類型設置存檔頁面。此掛鉤允許您過濾支援的文章類型的默認數組,以添加或刪除。該數組應包含有效文章類型的別名。請注意,數組鍵在使用時並不重要,但包含別名以便您輕鬆取消設置值。
例如:
add_filter( 'post_type_archive_pages/supported_post_types', function( $post_types ){
unset( $post_types['book'] );
return $post_types;
} );
過濾器 - post_type_archive_pages/taxonomy_post_type
默認情況下,如果該文章類型是該分類法所註冊的唯一文章類型,則分類法分類詞彙存檔將繼承文章類型的存檔頁面永久網址結構。例如,如果您有一個出版社分類法,則分類詞彙存檔的永久鏈接可能變為 /books/publisher/penguin。其中,/books 是存檔頁面的永久網址,publisher 是分類法別名,penguin 是詞彙別名。此掛鉤允許您更改此行為。
原文外掛簡介
Post Type Archive Pages allows you to select pages from within your content page structure to be the archive pages for your custom post types. This gives you control of the permalink for your archive pages and allows them to be nested under other pages. It also sets the permalink base for single posts of that post type and term archive for the post type’s taxonomies.
Once the plugin is installed and activated you’ll be able to select the archive page for each of your registered post types under Settings > Reading.
Templating
WordPress will look for archive page templates for the pages that you set as archive pages. So archive-$posttype.php and archive.php will be used rather than page.php.
There are also a few functions available that may be helpful in building themes. They are accessed on the plugin’s main instance, which is returned by a call to post_type_archive_pages().
get_archive_page
Returns the page object for the archive page of the provided post type slug. If called from a post type archive template, a singular template or a term archive and a slug isn’t provided, the relative post type will be used. e.g.
$page = post_type_archive_pages()->get_archive_page('book');
get_archive_page_post_type
Returns the post type object that the provided page ID is the archive page for. e.g.
$postType = post_type_archive_pages()->get_archive_page_post_type(5);
Menu – Enhancements
Archive pages added to the menu will be marked as the current menu item when viewing the post type archive and the current menu item’s parent / ancestor when viewing a post of that type. The related CSS classes will also be applied.
Advanced Custom Fields – Enhancements
This plugin is particularly effective when paired with Advanced Custom Fields. It registers additional page type location rules allowing you to add fields to all archive pages or the archive page for a particular post type. So if your listing page requires content like a description or header image you can place fields for those on the archive page itself.
To access fields like these in your archive template you need only call
$desc = get_field( 'description', post_type_archive_pages()->get_archive_page() );
Developer Hooks
The plugin attempts to set defaults that should work best for most scenarios. But there are some places to hook in and alter these defaults where needed.
Filter – post_type_archive_pages/supported_post_types
By default you will be able to set an archive page for any public post type other than the built in post types of page and post. This hook allows you to filter the default array of supported post types to add or remove. The array should contain slugs of valid post types. Please note that the array keys are not important in it’s use, but contain the slugs to allow you to easily unset values.
add_filter( 'post_type_archive_pages/supported_post_types', function( $post_types ){
unset( $post_types['book'] );
return $post_types;
} );
Filter – post_type_archive_pages/taxonomy_post_type
By default taxonomy term archives will inherit the archive page permalink structure of a post type if that post type is the only one that the taxonomy is registered on. For instance if you had a publisher taxonomy the permalink for a term archive might become /books/publisher/penguin. With /books being the permlaink of the archive page, publisher the taxonomy slug and penguin the term slug. This filter allows you to alter the post type who’s archive page permalink structure will be inherited for a given taxonomy.
add_filter( 'post_type_archive_pages/taxonomy_post_type', function( $post_type, $taxonomy ){
if ( $taxonomy === 'publisher' ) return null;
return $post_type;
}, 10, 2 );
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Post Type Archive Pages」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
1.0.0 | 1.0.1 | 1.0.2 | 1.0.3 | 1.0.4 |
延伸相關外掛(你可能也想知道)
Post Types Unlimited 》Post Types Unlimited 是一個輕鬆的方式,可以以正確的方式向你的 WordPress 網站添加自訂文章類型和自訂分類法 (taxonomy)。此外,這個外掛與任何佈景主題都...。
PixTypes 》, , 使用 PixTypes,您可以允許您的主題在啟用時定義自定義文章類型或元框。 , 注意:此外掛針對開發人員,如果沒有正確配置,它將不會執行任何操作。。
JSM Show Post Metadata 》JSM's Show Post Metadata外掛會在文章編輯頁面底部顯示文章(例如文章、頁面和自訂文章類型)的meta key(也就是自訂欄位名稱)和它們的非序列化值。, ...。
Convert Post Types 》這是一個用於批量轉換文章或頁面為自定義文章類型(或反之)的工具。您可以將轉換限制為單一類別中的文章或特定頁面的子代。您還可以分配新的分類法詞,這些...。
Display Post Types – Post Grid, post list and post sliders 》此外掛可輕鬆顯示文章網格、清單或文章輪播器,它以區塊或小工具的方式,提供最簡單的方式來獲取、排序和顯示文章、頁面或任何自訂文章類型的清單。輕易地建...。
Simple Custom Post Types 》從WordPress 3.1版本開始,擁有自定義文章類型的管理功能,而這個外掛使得管理過程更加簡單,不需任何編程知識。更新摘要可以更新您的佈景主題!, 這個外掛提...。
CMS Press 》CMS Press 提供了在 WordPress 網站上建立和管理自訂內容類型和分類法的能力。, 它增加了彈性,不只有文章和頁面,使用者可以註冊自己的 post_types,使用自...。
WP Sitemap Control 》此外掛允許你控制哪些文章類型應該包含在 WordPress 網站地圖中。預設地,網站地圖會包含所有公開文章類型和分類法,但現在你可以把選定類型的內容包含或排除...。
Smartlib Tools 》此外掛會在自訂器(如社交圖示)上新增一些額外選項,並為以下註冊分類和自訂文章類型:, - 投資組合項目, - 推薦人, - 常見問題, - 團隊成員, 此外掛不會更...。
Relations Post Types 》這個外掛可以建立兩種自訂類型(文章、頁面、自定義)之間的關聯,非常適合用於管理 CMS 網站上的相關內容。一些例子包括:, , 手動列出相關文章清單, 文章系...。
Pages Children 》外掛首頁, WordPress Pages 的管理有其缺陷,尤其當頁面分類結構過於複雜的情況下,接口就會變得不太實用。為了解決這個問題,開發者製作了 Pages-Children ...。
More Taxonomies 》這是早期的測試版 - 修復和更好的文件將會推出。我們保證。。
Custom Post Type Archives 》自從 WordPress 3.1 版本以來,它已經有了自己的自訂文章類型檔案庫實作,因此您可以在不使用此外掛的情況下創建它們 - 訪問此頁面以獲得更多信息-> https://...。
Recently Edited Content Widget 》這個外掛提供了一個資訊面板的小工具,以方便您快速訪問最近編輯的內容。, 選項 (每個使用者設定):, , 顯示項目數量, 引文長度 - 單位:字數 (0=隱藏), 僅顯...。
My Content Management 》My Content Management 建立了一組自定義文章類型,每個類型都有自定義分類和一組常見的自定義欄位。提供一個共同的界面來創建常用的內容工具。, 除了預設的...。