
內容簡介
這個外掛可以讓自訂選單「包含」其他自訂選單,因此可以定義重複出現在多個選單中的項目,只需在其中一個選單中定義一次,然後隨時包含在任何其他選單中。
如果您有一組選單項目在多個選單中重複出現,並且需要更新其中一個項目,您必須逐一更改每個選單,這可能有點煩人。
這個外掛允許您將該子集定義為單獨的選單,然後包含該選單到任何其他選單中。如果您需要維護子集中的其中一個項目,您只需要更新一個選單,而所有包含該子集的其他選單會自動反映該更改!
它使用起來跟將文章、頁面、分類或標籤添加到您的選單一樣簡單...
啟用外掛後,進入管理介面的選單頁面。除了能將文章、分類等添加到您的選單中外,您現在應看到一個導覽選單的元框,裡面有您定義的每個選單的核取方塊(如果您看不到這個元框,請在頁面頂部檢查您的螢幕選項設定)。您只需要像定義任何其他選單一樣,建立您的子選單,打開要插入新子選單的選單, 從導覽選單的元框中選擇子選單,加入它,並排列它。儲存後,您就完成了!
插入的選單會取代選單中的導覽選單項目。您可以將多個實例的同一個子選單插入一個選單中,而且可以將子選單包含在盡可能多的選單中。
持續環狀
這個外掛唯一防範的問題是避免進入無限迴圈狀態:它不會防止您設置環,但它不會輸出其本身作為前身之任何子選單。
例如,您可以設置這樣的選單:菜單A包括菜單B,菜單B包括菜單C。完全沒問題。然而,如果您還將菜單B添加到菜單C作為導覽選單項目,那麼無論您選擇輸出哪個選單,都有可能出現環路(… B,包括C,包括B,包括C,...等等)。
如果啟用了 WP_DEBUG,該外掛將在它採取措施防止迴圈條件的任何地方打印警告。這個行為可以通過鉤取過濾器進行更改(請參閱FAQs)。
僅限前端
該外掛僅在 WordPress 的前端執行選單替換(即不在管理介面頁面上執行)。這個行為可以通過鉤取過濾器進行更改(請參閱FAQs),但請確保您不要為選單管理頁面啟用它!
外掛標籤
開發者團隊
原文外掛簡介
This plugin enables a Custom Menu to “include” any other Custom Menu, so groups of items that get repeated across multiple menus can be defined just once and then included into any other menu at will.
If you have a set of menu items that you repeat across several menus, it can be a bit of a pain when
one of that set needs updating and you have to go through all your menus changing each one.
This plugin allows you to define the subset of items as a separate menu, and then include that menu
into any other menu. If you then need to maintain one of the items in the subset, you only need to update
one menu, and the change automatically gets reflected in all the other menus that include that subset!
It’s as easy to use as adding a Post, Page, Category or Tag to your menu…
With the plugin activated, go to your Menus page in admin.
As well as being able to add Posts, Categories, etc, to your menu, you should now see a metabox for
Navigation Menus which has checkboxes for each of your defined Menus (if you don’t see the metabox,
check your Screen Options settings at the top of the page).
All you need to do is create your submenu (as you would any other menu),
open the menu you want to insert the new submenu into,
select the submenu from the Navigation Menus metabox,
Add it,
and position it.
Save and you’re done!
The inserted Menu replaces the Navigation Menu item in the menu. You can insert multiple instances of the
same submenu into one menu, and you can include a submenu into as many other menus as you need.
Perpetual Loops
The one thing that the plugin guards against is getting into a never-ending loop : it won’t prevent you
setting one up (see FAQs as to why), but it will not output any submenu that has itself as an antecedent.
For example, you can set up menus such that Menu A includes Menu B, which includes Menu C. Fine, no problem.
However, if you were to also add Menu B into Menu C as a Navigation Menu item,
then no matter which menu you choose to output, you have a potential loop
(… B, includes C, includes B, includes C, … and so on).
If WP_DEBUG is enabled, the plugin will print a warning wherever it has taken action to prevent a loop condition.
This behaviour can be changed by hooking into a filter (see FAQs).
Frontend Only
The plugin only performs the menu replacement at the frontend of WordPress (ie. not on Admin pages).
This behaviour can be changed by hooking into a filter (see FAQs),
but please ensure that you do not enable it for the Menus admin page!
