10

I upgraded my PHP to 7.0 and after this I have this message in the header of my website:

Warning: Declaration of description_walker::start_el($output, $item, $depth, $args) should be compatible with Walker_Nav_Menu::start_el(&$output, $item, $depth = 0, $args = Array, $id = 0) in /homepages/2/d444683358/htdocs/wp-content/themes/zend/functions.php on line 59

Here is the line 59 in functions.php:

$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );

I'm not a coder so not sure what needs to be done to fix this?

Thanks for your help

1
  • 2
    It would be probably best to report it to theme's developers/support.
    – Rarst
    Commented Dec 12, 2016 at 15:49

1 Answer 1

32

The error message shows that the class description_walker extends the Walker_Nav_Menu class and overrides the start_el() method, but the signature differs from the method definition in the parent class.

As mentioned in comments, it would be best to contact the developer of your theme and ask for a corrected version of the theme.

If the developer cannot be reached or you really want to correct the theme yourself, you can do the following. But keep in mind that any changes to the theme files are overwritten on theme update.

Search the theme files for the function definition of start_el() inside the description_walker class. The line of code should look similar to this:

function start_el( $output, $item, $depth, $args ) {

Changing this line to the following should make the warning disappear:

function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
4
  • So, it is a PHP version cap issue?. This problem only started when moving a site from another host with diffrent PHP version... Strange I felt, no errors before... However this answer solved the Warning, as Im the owner of the theme walker... Thanks for a good answer as good it can be! Commented Nov 3, 2018 at 14:18
  • 2
    @JonasLundman This issue existed before PHP7 but in earlier versions, the warnings emitted had an error level of E_STRICT. Since PHP 7 they are normal warnings, hence they are shown with default error level settings.
    – JHoffmann
    Commented Nov 5, 2018 at 9:13
  • Thank you mate, you saved me ;) Commented Apr 5, 2019 at 17:09
  • Awesome man, thank you!
    – Siyah
    Commented Nov 25, 2019 at 18:58

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