[wp-hackers] wp_get_nav_menu_items not working?

Steve Taylor steve at sltaylor.co.uk
Tue Mar 8 13:15:45 UTC 2011


I've traced this issue all the way back through the core, and I think
it's something going wrong in get_term:


For clarity here's the path back:

- wp_get_nav_menu_items( "hero-carousel" ) calls
wp_get_nav_menu_object( "hero-carousel" ) (which returns nothing)
- wp_get_nav_menu_object( "hero-carousel" ) calls get_term(
"hero-carousel", 'nav_menu' ) (which returns nothing)

In get_term, the $term parameter is of course "hero-carousel" still.
At lines 815 and 819 (in taxonomy.php, above), it fails the object
tests because it's a string. Then, on line 821, casting it with int()
changes it to 0 (zero). From then on, nothing's working - the select
query returns nothing of course.

Now, if I pass the numeric ID of the menu - it works!


"Given a menu name, id or slug, the function returns the menu items
from that navigation menu."

Any idea what's going on here? Not so urgent now I've found a way, but
I have another site using the same method, calling
wp_get_nav_menu_items with a slug, and it works fine. The difference
is that this site hasn't been upgraded to 3.1 yet. Is this a bug in
the 3.1 core?


Steve Taylor

More information about the wp-hackers mailing list