[WordPress] 外掛分享: Automatic Submenu for Categories & Pages

首頁外掛目錄 › Automatic Submenu for Categories & Pages
WordPress 外掛 Automatic Submenu for Categories & Pages 的封面圖片
10+
安裝啟用
★★★☆☆
3/5 分(2 則評價)
3047 天前
最後更新
問題解決
WordPress 3.1+ v1.0.0 上架:2017-11-12

內容簡介

是否曾經想要自動將分類和頁面的子項目添加到您的菜單中?我確定我也是,但是發現沒有什麼簡單易用且不會干擾主題或其他外掛的東西。

現在,請耐心等待,因為這是我十年來的第一個 WP 外掛,也是第一次分享,所以我讓它變得很基本。

工作原理:

在每個類別或頁面的菜單項目上,您可以選擇自動添加其子項目作為子菜單
您可以決定顯示幾個子項目以及它們按標題或日期排序方式
就是這樣,您只需創建內容,就不必再擔心菜單。
正如承諾的那樣,它不會干擾主題或其他外掛,它只會在前端觸發導航菜單(nav menu)陣列中找到的相應位置注入子項目

代碼修改

這個外掛沒有設置頁面,但您可以從代碼自己更改一些默認行為

當該字段為空時更改默认最大子項目數
$item->automatic_max = 5;只需要在第220行更改數字

僅帶有頁面(Pages)直接後代,而不是所有祖先的子項目
$children = get_pages( array( 'child_of' => $item->object_id, 'number' => $item->automatic_max, 'sort_column' => 'post_'.$ordering[0], 'sort_order' => strtoupper( $ordering[1] ) ) ); 只需要在第226行將'child_of'改為 'parent'

即將推出的功能:

由於時間不足,我將根據需求實施以下功能。請在論壇上發布您的請求。

設置頁面
子菜單項目排序
支持自定義文章類型和稅onomies

特別感謝:

我使用了由 zviryatko 創建的菜單 Walker (https://plugins.trac.wordpress.org/browser/menu-image/trunk/menu-image.php)

外掛標籤

開發者團隊

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

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Automatic Submenu for Categories & Pages」→ 直接安裝(推薦)

原文外掛簡介

Ever wanted to be able to automatically have category and pages children automatically added to your menus? I’m sure I did and was disappointed to not find something that dead simple that works and doesn’t mess up with the theme or other plugins.
Now bear with me on this one as it is my first WP plugin for like a decade and the first ever to be shared so i kept it quite basic.
How it works:

On each menu item that is either a category or a page you get an option to automatically append their children as a submenu
You get to decide how many children to show and how they’re gonna be ordered (Title or Date)
And that’s it, all you have to do is create content and never worry about your menu again.
As promised, it doesn’t mess with the theme or other plugins, it just injects the children found in the corresponding place of the nav menu array when that is triggered in the frontend

Code hacks
There is no settings page for the plugin but you can change a couple default behaviours from the code itself
Changing the default maximum children number when the field is empty
$item->automatic_max = 5; just change the number at line 220

Bring only direct children of Pages and not all ascendants
$children = get_pages( array( 'child_of' => $item->object_id, 'number' => $item->automatic_max, 'sort_column' => 'post_'.$ordering[0], 'sort_order' => strtoupper( $ordering[1] ) ) ); just change 'child_of' to 'parent' at line 226

Upcoming Features:
Due to lack of time i will implement the following features upon demand. Please post your requests in the forum.

Settings Page
Submenu items ordering
Support for custom post types and taxonomies

Credits:

I have used the menu walker created by zviryatko (https://plugins.trac.wordpress.org/browser/menu-image/trunk/menu-image.php)

延伸相關外掛

文章
Filter
Apply Filters
Mastodon