On a few occasions now I already have seen an issue with the Strict Standards Compatibility Custom Walker WP Nav Menu.

Of course you can only see those errors when you have set WP_DEBUG to true in your wp-config.php file.

Why would you want to build a Custom Walker in the first place?

Well, for example if you want to add a description to the navigation menu, so that it reads both the menu item name and the description of it. After all description is one of the features you can add if you open the Screen Options menu on the Appearance > Menus page in the WordPress Dashboard!

The code needed to build the Custom Walker for this is available on a variety of websites, just do a search for show description wp_nav_menu and you can pick any of the results.

However, what all these sites have in common is that the function they use for the Custom Walker is throwing a Strict PHP Error, namely:

Strict Standards: Declaration of Your_Custom_Walker::start_el() should be compatible with Walker::start_el(&$output, $object, $depth = 0, $args = Array, $current_object_id = 0) in [your-file-name.php]

The solution for this is to replace the name of the function:

1
2
// Previous function
function start_el(&$output, $item, $depth, $args) {}
1
2
// Current function
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {}
Send a Message