Error: Declaration of MyClass::start_lvl() should be compatible with that of Walker_Nav_Menu::start_lvl()

I’m currently working on a WordPress site and whenever in the admin I go the Appearance > Menus page I get the following error:

ErrorException: Runtime Notice: Declaration of Walker_Nav_Menu_Edit::start_lvl() should be compatible with that of Walker_Nav_Menu::start_lvl() in wp-admin/includes/nav-menu.php line 203

It seems like some sort of PHP compatibility issue. I’m running PHP 5.3.10 on my local dev machine.

What would be the best way to remedy this problem?

3

From class Walker_Nav_Menu:

function start_lvl( &$output, $depth = 0, $args = array() )

Your child class must use the same signature: three arguments, the first one passed by reference. Every difference will raise the error you got.

Note that $args defaults to an empty array, but you get an instance of stdClass, not an array. This is WordPress.

Leave a Comment