Title: Navigation Menu IDs &amp; Classes
Author: Aaron T. Grogg
Published: <strong>2011 年 9 月 30 日</strong>
Last modified: 2015 年 5 月 15 日

---

搜尋外掛

這個外掛**並未在最新的 3 個 WordPress 主要版本上進行測試**。開發者可能不再對這個
外掛進行維護或提供技術支援，並可能會與更新版本的 WordPress 產生使用上的相容性問題。

![](https://s.w.org/plugins/geopattern-icon/navigation-menu-ids-classes.svg)

# Navigation Menu IDs & Classes

 由 [Aaron T. Grogg](https://profiles.wordpress.org/aarontgrogg/) 開發

[下載](https://downloads.wordpress.org/plugin/navigation-menu-ids-classes.2.6.zip)

 * [詳細資料](https://tw.wordpress.org/plugins/navigation-menu-ids-classes/#description)
 * [使用者評論](https://tw.wordpress.org/plugins/navigation-menu-ids-classes/#reviews)
 *  [安裝方式](https://tw.wordpress.org/plugins/navigation-menu-ids-classes/#installation)
 * [開發資訊](https://tw.wordpress.org/plugins/navigation-menu-ids-classes/#developers)

 [技術支援](https://wordpress.org/support/plugin/navigation-menu-ids-classes/)

## 外掛說明

This plug-in limits the classes WordPress added to navigation menus to only those
desired by the Theme owner,
 adds a unique ID to each `li` and removes any empty`
class` attributes.

More about this plug-in can be found at:
 http://aarontgrogg.com/2011/09/28/wordpress-
plug-in-navigation-menu-ids-classes/

Please let me know if you have any questions/suggestions/thoughts,

Atg

## 安裝方式

 1. Download the ZIP
 2. Unzip the ZIP
 3. Copy/paste the unzipped files into your WP plug-in directory (`/wp-content/plugins/`)
 4. From within WP’s Plugin Admin panel, Activate the ‘Navigation Menu IDs & Classes’
    plug-in
 5. Choose which, if any, WP classes you wish to have in your HTML
 6. Marvel at the power of technology!

## 常見問題集

  Why bother?

 * WP bakes in a ton of extraneous, border-line-useless, IDs and classes on navigation
   menu LIs (are you really going to
    target `id="menu-item-72"` or `class="page-
   item-58"` in your CSS?). This plug-in greatly reduces those classes, and adds
   classes that reflect the link’s page name, in slug form, so you can easily target
   menu LIs in your CSS.

  What WP classes are allowed to remain?

 * Any that you choose.

  Does this work with standard and custom menus?

 * Yes, both standard and custom menus will get class names that reflect the page
   name from the link they contain, such as:
 * [About Us](https://tw.wordpress.org/plugins/navigation-menu-ids-classes/about-us?output_format=md)

## 使用者評論

![](https://secure.gravatar.com/avatar/e52219e35dd38ce9b5cd5c5ba65b218e576f04673884f8f56995d5fe6b3d3d82?
s=60&d=retro&r=g)

### 󠀁[1 for inclusion in core](https://wordpress.org/support/topic/1-for-inclusion-in-core/)󠁿

 [nimmolo](https://profiles.wordpress.org/nimmolo/) 2016 年 9 月 3 日 1 則留言

At least some aspect of this plugin seems like it should be available in WordPress
core. I understand the rationale for menu items having menu-item-ID, but it's pretty
practical for them to have the slug in there, as this plugin provides. Suggestion
for plugin feature – offer option for slug prefix. Like if I have a menu item "updates"
I may use the class "updates" elsewhere, but class "menu-item-updates" would target
the menu-item for sure. Of course I can currently use double selectors.

 [ 閱讀全部 5 則使用者評論 ](https://wordpress.org/support/plugin/navigation-menu-ids-classes/reviews/)

## 參與者及開發者

以下人員參與了開源軟體〈Navigation Menu IDs & Classes〉的開發相關工作。

參與者

 *   [ Aaron T. Grogg ](https://profiles.wordpress.org/aarontgrogg/)

[將〈Navigation Menu IDs & Classes〉外掛本地化為台灣繁體中文版](https://translate.wordpress.org/projects/wp-plugins/navigation-menu-ids-classes)

### 對開發相關資訊感興趣？

任何人均可[瀏覽程式碼](https://plugins.trac.wordpress.org/browser/navigation-menu-ids-classes/)、
查看 [SVN 存放庫](https://plugins.svn.wordpress.org/navigation-menu-ids-classes/)，
或透過 [RSS](https://plugins.trac.wordpress.org/log/navigation-menu-ids-classes/?limit=100&mode=stop_on_copy&format=rss)
訂閱[開發記錄](https://plugins.trac.wordpress.org/log/navigation-menu-ids-classes/)。

## 變更記錄

#### 2.5

2015-03-13:
 * Fixing issue if no cusotm classes exist

#### 2.4

2013-07-11:
 * Added ability to retain custom class added via the Menus Admin page;
thanks to Bryce for the idea, and sorry it took me so long to get around to!

#### 2.3

2013-04-07:
 * Fixed naming issue preventing plug-in from working and fixed screenshots

#### 2.1

2013-01-11:
 * Fixed an issue where individual checkboxes seemed to not respond 
to click (in fact, thanks to WP’s layout and jQuery’s bubbling, my toggle function
was toggling twice). Was able to fix issue and remove the toggle function altogether.
Thanks, Erin Allen! * Fixed an issue where the `for` attribute for all of the `label`
s was not getting added correctly. Now the `label` for each row spans the entire
row, meaning you can click anywhere in a row to toggle that checkbox. * Changed `
NMIC.checkboxes.attr` to `NMIC.checkboxes.prop` in the `checkall` and `uncheckall`
functions.

#### 2.0

2012-10-03:
 * Finally added the admin screen! * Added `if ( ! function_exists( '...')):`
blocks around each plug-in function * Changed function namesspace from `nmic` to`
NMIC` * Still want to find a way to gather possible WP class names programmatically,
for “this” version of WP; any ideas?

#### 1.2

2012-02-27:
 * Page name slug classes were not working; this has been fixed. Thanks
to Christopher Bright for getting me to look into this. * Removed nmic_remove_empty_classes
function, as it is no longer necessary now that all nav menu LIs will have at least
one class: the page name slug.

#### 1.0

2011-09-28:
 Well, this is the first version, so… here it is, hope you like it!

## 中繼資料

 *  版本 **2.5**
 *  最後更新 **11 年前**
 *  啟用安裝數 **100+**
 *  WordPress 版本需求 ** 3.0 或更新版本 **
 *  已測試相容的 WordPress 版本 **4.1.42**
 *  語言
 * [English (US)](https://wordpress.org/plugins/navigation-menu-ids-classes/)
 * 標籤:
 * [id](https://tw.wordpress.org/plugins/tags/id/)[menu](https://tw.wordpress.org/plugins/tags/menu/)
   [navigation](https://tw.wordpress.org/plugins/tags/navigation/)[semantic](https://tw.wordpress.org/plugins/tags/semantic/)
 *  [進階檢視](https://tw.wordpress.org/plugins/navigation-menu-ids-classes/advanced/)

## 評分

 4.8 星，滿分為 5 星

 *  [  4 個 5 星使用者評論     ](https://wordpress.org/support/plugin/navigation-menu-ids-classes/reviews/?filter=5)
 *  [  1 個 4 星使用者評論     ](https://wordpress.org/support/plugin/navigation-menu-ids-classes/reviews/?filter=4)
 *  [  0 個 3 星使用者評論     ](https://wordpress.org/support/plugin/navigation-menu-ids-classes/reviews/?filter=3)
 *  [  0 個 2 星使用者評論     ](https://wordpress.org/support/plugin/navigation-menu-ids-classes/reviews/?filter=2)
 *  [  0 個 1 星使用者評論     ](https://wordpress.org/support/plugin/navigation-menu-ids-classes/reviews/?filter=1)

[撰寫評分](https://wordpress.org/support/plugin/navigation-menu-ids-classes/reviews/#new-post)

[查看全部使用者評論](https://wordpress.org/support/plugin/navigation-menu-ids-classes/reviews/)

## 參與者

 *   [ Aaron T. Grogg ](https://profiles.wordpress.org/aarontgrogg/)

## 技術支援

使用者可在技術支援論壇提出意見反應或使用問題。

 [檢視技術支援論壇](https://wordpress.org/support/plugin/navigation-menu-ids-classes/)