Search by

proteusthemes / wai-aria-walker-nav-menu

rkon_ptngalt_pt

WordPress menu walker for dropdown menus.

Package info

github.com/proteusthemes/WAI-ARIA-Walker_Nav_Menu

pkg:composer/proteusthemes/wai-aria-walker-nav-menu

Statistics

Installs: 8 276

Dependents: 0

Suggesters: 0

Stars: 32

Open Issues: 3

v1.3.0 2026-11-14 03:24 UTC

This package is auto-updated.

Last update: 2026-11-14 03:36:21 UTC


README

Nav menu walker for WP dropdown menus.

Install

Detailed explanation in a blogpost.

  1. You can install this class using Composer (preferred method) or manually copying this file to your theme / project.

  2. After that, include it in your theme, probably something like (assuming you installed it using Composer):

require_once 'vendor/proteusthemes/wai-aria-walker-nav-menu/aria-walker-nav-menu.php';

The walker adds no ARIA attributes or tabindex to menu items, so you don't need to enqueue wai-aria.js; the file stays in the package for themes that already load it. To open submenus for keyboard users, add :focus-within next to the :hover rules that show them.

  1. Finally, include the menus in your theme files as per example below:
<nav class="collapse  navbar-collapse" role="navigation" aria-label="<?php _e( 'Main Menu', 'your-textdomain' ); ?>">
  <?php
  	if ( has_nav_menu( 'your-menu' ) ) {
  		wp_nav_menu( array(
  			'theme_location' => 'your-menu',
  			'container'      => false,
  			'menu_class'     => 'main-navigation',
  			'walker'         => new Aria_Walker_Nav_Menu(),
  			'items_wrap'     => '<ul id="%1$s" class="%2$s">%3$s</ul>',
  		) );
  	}
  ?>
</nav>

Mind:

  • 'walker' => new Aria_Walker_Nav_Menu(),
  • <nav> wrapping element and 'container' => false in the arguments
  • role="navigation"
  • aria-label="<?php _e( 'Main Menu', 'your-textdomain' ); ?>"
  • 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',

Compatibility with WP

This repo aims to be 1:1 compatible with latest WP version, mainly with the class Walker_Nav_Menu in the file /<path-to-wp>/wp-includes/nav-menu-template.php.

Current version is compatible with WP core 4.5.

Contributing

No need to explain - fork me and create a pull request.

Created by @primozcigler and @Prelc.