remove li class & id for menu items and pages list

后端 未结 8 1398
青春惊慌失措
青春惊慌失措 2021-01-30 23:24

Example of WordPress default CSS class output:

  • &l
  • 8条回答
    •  执笔经年
      2021-01-31 00:02

      My solution:

      $defaults = array(
          'theme_location'  => '',
          'menu'            => '',
          'container'       => '',
          'container_class' => '',
          'container_id'    => '',
          'menu_class'      => '',
          'menu_id'         => '',
          'echo'            => false, // param important
          'fallback_cb'     => 'wp_page_menu',
          'before'          => '',
          'after'           => '',
          'link_before'     => '',
          'link_after'      => '',
          'items_wrap'      => '',
          'depth'           => -1,
          'walker'          => ''
      );
      
      ob_start();
      echo preg_replace( '#]+>#', '
    • ', wp_nav_menu( $defaults ) ); $mainNav = ob_get_clean(); // In the page : echo $mainNav;
    提交回复
    热议问题