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

Read More

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?

Related posts

Leave a Reply

3 comments

  1. 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.

  2. From class Walker_Nav_Menu replace this lines

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

    to

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

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

    to

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

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

    to

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

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

    to

    function end_el(&$output, $category, $depth = 0, $args = array()) {
    
  3. This was the same in my case. You get old nav menu walker codes, and it says what you should do when you turn on wp_debug(true)

    Menu_Frontend::start_lvl(&$output, $depth) should be compatible with Walker_Nav_Menu::start_lvl(&$output, $depth = 0, $args = NULL) in C:xampphtdocsshopnetwp-contentthemesViteeohades_frameworkhelpermegamenu.php on line 314

    As you can see you need to change some code line what PHP refers to you. In above error notice you should replace start_lvl(&$output, $depth) with start_lvl(&$output, $depth = 0, $args = NULL)
    so other processes are the same. But don’t forget to write function opening tag { at the end, like this NULL) {