[WordPress] 外掛分享: Category Posts in Custom Menu

首頁外掛目錄 › Category Posts in Custom Menu
2,000+
安裝啟用
★★★★
4.8/5 分(43 則評價)
105 天前
最後更新
問題解決
WordPress 5.4+ PHP 7.4+ v3.0.5 上架:2011-11-07

內容簡介

此外掛可讓你列出屬於分類法(類別、標籤等)的文章和頁面,並自動替換為文章和頁面本身,並且也支援自訂分類法和自訂文章類型!相容PHP 7.0。

使用方法

啟用此外掛後前往外觀 > 選單加入分類法(類別/標籤/自訂)至選單中。接著你可以選擇是否要替換原本的連結(列出專屬頁面的所有項目)為文章頁面本身。

對於選單中的每個類別和標籤項目,你現在擁有以下額外設定選項:

在選單中是否用文章列表替換連結 y/n;
指定你希望顯示您此項目的文章數量上限(-1 =全部,0也可);
依據文章的ID、作者、標題和其他屬性遞增或遞減排序。請見「其他說明 > 排序」;
保留或刪除原先的選單項目(總是/僅在沒有文章時/不顯示);
指定選單項目的標題。你可以使用%post_title、%post_author和其他特殊字元,請見「其他說明 > 特殊字元」。

細節

此外掛使用wp_nav_menu_objects過濾器勾選來刪除和取代選單中的分類法項目。它擴展Walker_Nav_Menu_Edit以添加輸入字段到外觀 > 選單,並添加一些CSS樣式以適當的樣式顯示。

此外掛現在支援wp_nav_menu_item_custom_fields鉤子點,並且應與其他使用此鉤子點的外掛相容。

特殊字元

你可以使用以下特殊字元來控制此外掛所生成的選單項目的標題:

%post_title
%post_author
%post_featured_image_url
%post_featured_image(插入具有特色圖像的HTML「img」標籤,如果沒有圖像則為無)
%post_featured_image_thumb_url
%post_featured_image_thumb(插入具有特色圖像縮略圖的HTML「img」標籤,如果沒有圖像則為無)
%post_excerpt
%post_url
%post_date用於未格式化的文章日期:2012-11-10 18:14:23
%post_date()用於帶有以下預設格式的格式化文章日期:2012年11月10日
%post_date(<your formatting here>) 用於自訂日期格式。範例:%post_date(l jS \of F Y, h:i:s A)。有關格式選項,請參閱https://codex.wordpress.org/Formatting_Date_and_Time。
%post_date_gmt
%post_date_gmt()
%post_date_gmt(<your formatting here>)
%post_status
%post_modified
%post_modified()
%post_modified(<your formatting here>)
%post_modified_gmt
%post_modified_gmt()
%post_modified_gmt(<your formatting here>)
%post_comment_count
自訂文章欄位的特殊字元,例如%post_my_field,其中「我的欄位」或「my_field」是自訂欄位

以下特殊字元已被廢止:

%post_feat_image(僅限URL)
%post_feat_image_thumb(僅限URL)

排序

你可以依據以下屬性遞增或遞減排序,來控制選單項目的排序:

無排序
ID
作者
標題
日期
上次修改日期

外掛標籤

開發者團隊

⬇ 下載最新版 (v3.0.5) 或搜尋安裝

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

原文外掛簡介

The default custom menu in WordPress only allows adding a link that leads to a list of posts and pages belonging to a taxonomy (category, tag, etc). If you want to list the posts and pages themselves and if you want WordPress to do this automatically for you, then I hope you will find this plugin useful.
Also works for custom taxonomies and custom post types
NEW: CPCM V3 now provides support for Full Site Editing with the Gutenberg Block Editor
WARNING: Coming from version 1.x? There are breaking changes, read the changelog before upgrading.
Using it
Enable the plugin and go to either Appearance > Menus or Appearance > Customize or Appearance > Editor. Add a category (or other taxonomy like tag or custom) to the menu. Next, you can choose if you would like to replace the category by the posts or pages themselves.
For each Category in your menu, you now have the following extra configuration options:

Replace by posts in the category y/n;
specify the (maximum) number of posts you want to show for this item (max 10);
their ordering ascending or descending by Title, Date or Menu Order;
specify the title for the menu items. For this you can use %post_title, %post_author and other wildcards, see ‘Other Notes > Wildcards’. Default value: %post_title

Wildcards
You can control the title of the menu items generated by the plug-in with the following wildcards:

%post_title
%post_author
%post_date for the unformatted post date: 2012-11-10 18:14:23
%post_date() for a formatted post date with the following default formatting: November 10th, 2012
%post_date() for custom date formatting. Example: %post_date(l jS \of F Y, h:i:s A). See https://codex.wordpress.org/Formatting_Date_and_Time for formatting options.
%post_date_gmt
%post_date_gmt()
%post_date_gmt()

延伸相關外掛

文章
Filter
Mastodon