PHP code example of craigpearson / bem-walker-nav-menu
1. Go to this page and download the library: Download craigpearson/bem-walker-nav-menu library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
craigpearson / bem-walker-nav-menu example snippets
<nav class="nav">
wp_nav_menu([
'walker' => new CP\BEM\navWalker,
]);
// Will generate:
// <ul id="..." class="nav__list">
// <li class="nav__item ... nav__item--123">
// <a href="..." class="nav__link">...</a>
// <ul class="sub-nav">
// <li class="sub-nav__item">
// ...
class CustomWalkerNavMenu extends \CP\BEM\navWalker
{
protected $prefix = 'c';
protected $navListClass = 'menu__list';
protected $navItemClass = 'menu__item';
protected $navLinkClass = 'menu__link';
protected $subNavClass = 'sub-menu';
protected $subNavItemClass = 'sub-menu__item';
protected $subNavLinkClass = 'sub-menu__link';
}