Jump to content

Search the Community

Showing results for tags 'custom menu walker'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 1 result

  1. Hey all. I'm fairly new to WordPress (not php) and am running into an issue. I need to add link descriptions to 1 of 5 menus on my page. I've read about extending Walker_Nav_Menu() and am attempting that, and it's kinda going well except for one slightly annoying issue - it's returning the wrong menu. I'm attempting to isolate the action to a menu with the slug 'subbrand-menu'. All the code follows: mytheme/functions.php require_once('classes/FunctionClass.php'); $fn = new MyDev\FunctionClass(); add_filter('wp_get_nav_menu_items',array($fn,'buildSubbrandMenu'),10,2); mytheme/classes/FunctionClass.php namespace MyDev; class FunctionClass{ private $_walker; public function buildSubbrandMenu($menu, $args){ if(\is_admin() || $args->slug !== 'subbrand-menu'){ return $menu; } if(empty($this->_walker)){ require_once('MyWalker.php'); $this->_walker = new MyWalker; } \wp_nav_menu(array( 'menu' => 'subbrand_menu', 'container' => 'div', 'container_class' => 'menu-subbrand-menu-container', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => 'menu-subbrand-menu', 'echo' => true, 'walker' => $this->_walker )); } } mytheme/classes/MyWalker.php namespace MyDev; class MyWalker extends \Walker_Nav_Menu{ public function end_el(&$output, $item, $depth=0, $args=array()) { $output .= "<span class='thisisadescr'>Testing, testing</span></li>"; } } Now, the above actually works quite well except that it's outputting the contents of a menu with the slug 'floater'. Anybody have any ideas what I'm missing here? I'm sure it's something simple but it's driving me crazy right now. Thanks in advance for any and all thoughts, hints, tips, and ideas.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.