PHP - Moved: Wordpress Menu Creator
This topic has been moved to CSS Help.
http://www.phpfreaks.com/forums/index.php?topic=347669.0 Similar TutorialsThis topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=352987.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=310048.0 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. This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=327275.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=334215.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=358684.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=311671.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=314030.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=314808.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=347443.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=351799.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=343992.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=348006.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=333014.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=358438.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=350210.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=318784.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=322006.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=334084.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=353224.0 |