将过滤器添加到WP Bootstrap Navwalker

时间:2019-07-15 21:59:51

标签: php wordpress wp-nav-walker

我需要更新WP Boostrap Navwalker,以允许父菜单项包括菜单中的链接。我正在阅读解决方案here,但是由于我正在处理儿童主题,因此无法直接访问navwalker文件。

所以我想知道是否有一种方法可以创建一个过滤器来对此进行更新:

  if ($args->has_children && $depth === 0) {
                $atts['href']           = '#';
                $atts['data-toggle']    = 'dropdown';
                $atts['class']          = 'dropdown-toggle';
                $atts['aria-haspopup']  = 'true';
            } else {
                $atts['href'] = ! empty($item->url) ? $item->url : '';
            }

对此:

    if ( $args->has_children && $depth === 0 ) {
        $atts['href']           = ( $item->url );
        $atts['data-toggle']    = 'dropdown';
        $atts['class']          = 'dropdown-toggle disabled';
        $atts['aria-haspopup']  = 'true';
    } else {
        $atts['href'] = ! empty( $item->url ) ? $item->url : '';
    }

不确定执行此操作的最佳方法。

0 个答案:

没有答案
相关问题