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?


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.

  • I know. It's a WordPress class, it's not for me to change. My question is what's the best way to work around the problem (preferably without meddling with WP's internals)... – Luke Apr 9 '13 at 4:41
  • 3
    You are not being told to meddle with WordPress core. You need to alter the way you define your method in your extended class to match the way WordPress does it in the original class. – s_ha_dum Apr 9 '13 at 13:17
  • 1
    Got it. The error was throwing me off. It gave me the impression the problem was in WP core but it's referring to the definition of the signature, not where the problem occurred. – Luke Apr 9 '13 at 23:04

From class Walker_Nav_Menu replace this lines

function start_el(&$output, $category, $depth, $args) {


function start_el(&$output, $category, $depth = 0, $args = array(), $current_object_id = 0) {

function end_lvl(&$output, $depth, $args) {


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

function start_lvl(&$output, $depth, $args) {


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

function end_el(&$output, $category, $depth, $args) {


function end_el(&$output, $category, $depth = 0, $args = array()) {
  • Can you also explain how it works instead of just adding the code and how is it different from the accepted answer – bravokeyl Sep 23 '17 at 10:45
  • Yes; The answer is updated in 2015, and it does not work on the new version of Wordpress link – Mohammad Abedi Sep 23 '17 at 13:54
  • Yes, so explanation of the answer would be awesome. – bravokeyl Sep 23 '17 at 17:18
  • This saved my ass, definitely the correct answer if you have 4 error messages, for function start_el, function end_el, function start_lvl, function end_lvl – Stephen Jun 8 '18 at 16:29
  • Where or how we go to the class Walker_Nav_Menu??? I do not know how or where It is selected!!!!! – riemannium Nov 13 '19 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.