错误详情:
Warning: Declaration of description_walker::start_el(&$output, $item, $depth, $args) should be compatible with Walker_Nav_Menu::start_el(&$output, $data_object, $depth = 0, $args = NULL, $current_object_id = 0) in
你遇到的这个警告,核心原因是自定义导航菜单类 description_walker 重写的 start_el 方法,参数列表和 WordPress 核心父类 Walker_Nav_Menu 不匹配,PHP 抛出兼容警告。
解决办法:
父类 Walker_Nav_Menu 的 start_el 方法标准参数为:
public function start_el(&$output, $data_object, $depth = 0, $args = null, $current_object_id = 0)
而你的子类 description_walker 的 start_el 方法参数缺少默认值和最后一个参数,且变量名 $item 与父类的 $data_object 不一致,导致兼容警告。


没有回复内容