Hello, i’m new to WordPress so probably i’m doing something very wrong here but.. i’m really puzzled with this, hopefully you guys can help me out!
Basically what i want is to add the page slug as a class to each of my menu li tags and add a span around the text. I’m using a twenty eleven child theme. In my functions.php file i define this walker function as described in this article. This doesn’t work, along with many other walker examples I found on other websites.
I’ve also tried to copy the Walker_Nav_Menu function from the nav-menu-template.php and use this in my functions.php. Doesn’t work either. It gets called and everything but I will end up with all empty li and anchor tags. No attributes, no url, no text, just the tags…
Through print_r()’s I eventually found out that the $item param in the start_el function has different properties than assumed by the code. The php code assumes there are properties like $item->attr_title, $item->target, $item->xfn, $item->url, etc. Printing out the $item class show there are no such properties. What i get with print_r($item) is:
stdClass Object ( [ID] => 10 [post_author] => 1 [post_date] => 2012-02-03 19:21:33 [post_date_gmt] => 2012-02-03 19:21:33 [post_content] => test [post_title] => test [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => test [to_ping] => [pinged] => [post_modified] => 2012-02-03 19:21:33 [post_modified_gmt] => 2012-02-03 19:21:33 [post_content_filtered] => [post_parent] => 0 [guid] => http://192.168.0.130/wordpress/?page_id=10 [menu_order] => 0 [post_type] => page [post_mime_type] => [comment_count] => 0 [filter] => raw )
Anyone have any ideas where this is coming from?
- The topic ‘wp_nav_menu walker outputs empty tags with no attrbutes, no content’ is closed to new replies.