-
-
Save grok/10508187 to your computer and use it in GitHub Desktop.
<?php | |
class My_Walker extends Walker_Nav_Menu { | |
} | |
?> |
<?php | |
echo '##### COMMENSE MY WALKER #####' . "\n"; | |
wp_nav_menu( | |
array( | |
'walker' => new My_Walker() | |
) | |
); | |
echo '##### COMPLETE MY WALKER #####'; | |
echo "\n\n"; | |
echo '##### COMMENSE CORE WALKER #####' . "\n"; | |
wp_nav_menu(); | |
echo '##### COMPLETE CORE WALKER #####'; | |
?> |
<?php get_header(); ?> |
##### COMMENSE MY WALKER ##### | |
<br /> | |
<b>Notice</b>: Trying to get property of non-object in <b>/wp-includes/nav-menu-template.php</b> on line <b>148</b><br /> | |
<br /> | |
<b>Notice</b>: Trying to get property of non-object in <b>/wp-includes/nav-menu-template.php</b> on line <b>151</b><br /> | |
<br /> | |
<b>Notice</b>: Trying to get property of non-object in <b>/wp-includes/nav-menu-template.php</b> on line <b>151</b><br /> | |
<br /> | |
<b>Notice</b>: Trying to get property of non-object in <b>/wp-includes/nav-menu-template.php</b> on line <b>153</b><br /> | |
<div class="menu"><ul><li id="menu-item-2" class="menu-item-2"><a></a></li></ul></div> | |
##### COMPLETE MY WALKER ##### | |
##### COMMENSE CORE WALKER ##### | |
<div class="menu"><ul><li class="page_item page-item-2"><a href="/?page_id=2">Sample Page</a></li></ul></div> | |
##### COMPLETE CORE WALKER ##### |
Solution seems to be to take references to $args and instead of doing $arg->value switch it to $arg['value']
Current Solutions
Until ticket #24587 is resolved, this can be fixed by redeclaring the functions from core in my extended class and just changing to arrays or typecasting.
If you go to nav-menu-template.php and just copy out the code for Walker_Nav_Menu into your walker and change $args->whatever to $args['whatever'] -- this should fix it.
I know this is C&P and a shit way to go about it - but it's a known bug and all we can do at the moment.
This is actually only a problem up until you create a menu in the back end, give it an item, and assign it to the menu location.
"This is actually only a problem up until you create a menu in the back end, give it an item, and assign it to the menu location."
What happens if you...
wp_nav_menu(array('walker' => new My_Walker(), 'fallback_cb' => false));
@JoshKoberstein are you speaking towards AFTER you have created a menu entry and have >= 1 menu item in it?
This problem only manifests if you write the code and no menu exists in the system as far as I can tell.
P.S. I'm including @ notation with your name so that when they get that working it should display properly :)
PHP 5.4.24
WordPress. Version 3.8.2