小编Bra*_*ell的帖子

Walker 类的 Wordpress 问题

什么是 isset 或 empty 中的非法偏移类型,我以前从未遇到过此错误消息?你能向我解释一下这条消息吗?

还在评论中放置了学习如何做的代码

  <?php
  if (has_nav_menu('primary_navigation')) :
    wp_nav_menu( array(
      'theme_location' => 'primary_navigation',
      'menu_class' => 'menu',
      'menu_class' => 'mobile-menu',
      'walker' => new  Walker_Nav_Primary (),
      )
    );
  endif;
  ?>

class Walker_Nav_Primary extends Walker {
  function start_lvl( &$output, $depth = 0, $args = array() ) { //ul
    $indent = str_repeat("\t",$depth);
    $submenu = ($depth > 0) ? ' sub-menu' : '';
    $output .= "\n$indent<ul class=\"fallback$submenu depth_$depth\">\n";
  }
Run Code Online (Sandbox Code Playgroud)
警告:第 140 行 /Users/brandonpowell/sites/valet/wordpress-development/web/wp/wp-includes/class-wp-walker.php 中的 isset 或空的非法偏移类型

php wordpress

2
推荐指数
1
解决办法
1119
查看次数

标签 统计

php ×1

wordpress ×1