MAJpage Menu Class Extender

Adds classes to first, last, parent, even and odd elements of wp_nav_menu.

Author:Wiktor Maj (profile at wordpress.org)
WordPress version required:3.0.0
WordPress version tested:5.2.3
Plugin version:1.6
Added to WordPress repository:12-08-2011
Last updated:08-09-2019
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Rating, %:100
Rated by:1
Plugin URI:
Total downloads:5 746
Active installs:90+
plugin download
Click to start download

This simple plugin was written to add classes to first, last, parent, even and odd elements of wp_page_menu and wp_nav_menu to support recognizing it in older browsers without :first-child, :last-child and :nth-child supporting.

Plugin adds the following classes to menu <li> tags:

  • “first-menu-item” to every first child of <ul> or <menu> tag,
  • “last-menu-item” to every last child of <ul> or <menu> tag,
  • “parent-menu-item” to every child of <ul> or <menu> tag that has another <ul> or <menu> tag inside (a parent to another menu level),
  • “odd-menu-item” to every odd child of <ul> or <menu> tag, including first and/or last child,
  • “even-menu-item” to every even child of <ul> or <menu> tag, including first and/or last child.

    Above classes are added separately to each menu level. Plugin use SimpleXML extension and requires PHP 5 or higher. Menu should have valid XHTML code.


ChangeLog