0

我有一个 Wordpress Bootstrap 网站。我为下拉菜单功能实现了 WP Bootstrap Navwalker,没有问题。我使用此处提供的代码示例按照说明进行操作:https ://github.com/wp-bootstrap/wp-bootstrap-navwalker 。一切都很好。

但是,下拉图标在左侧!

我添加了几个不同的图标只是为了测试,但它总是显示在左侧。我将其更改为向右箭头,因为它困扰着我。

在此处输入图像描述

我用于代码的内容正是他们网站上的内容,例如稍作修改。

  wp_nav_menu(array(
    'theme_location'  => 'menu-1',
    'container'       => 'div',
    'container_class' => 'navbar-collapse collapse',
    'container_id'    => 'navcol-1',
    'menu_class'      => 'nav navbar-nav ml-auto',
    'depth'           => 2,
    'echo'            => true,
    'fallback_cb'     => 'WP_Bootstrap_Navwalker::fallback',
    'walker'          => new WP_Bootstrap_Navwalker()
    ));
        ?>

    if ( ! file_exists( get_template_directory() . '/inc/class-wp-bootstrap-navwalker.php' ) ) {
        // File does not exist... return an error.
        return new WP_Error( 'class-wp-bootstrap-navwalker-missing', __( 'It appears the class-wp-bootstrap-navwalker.php file may be missing.', 'wp-bootstrap-navwalker' ) );
    } else {
        // File exists... require it.
        require_once get_template_directory() . '/inc/class-wp-bootstrap-navwalker.php';
    }

    add_action( 'after_setup_theme', 'register_navwalker' );

任何人都遇到过这个,或者可能知道我做错了什么?

4

1 回答 1

1

查看自定义 walker 看起来像这一行是为什么图标是第一位的:

$item_output .= isset( $args->link_before ) ? $args->link_before . $icon_html . $title . $args->link_after : '';

您可以将其更新为:

$item_output .= isset( $args->link_before ) ? $args->link_before . $title . $icon_html . $args->link_after : '';

但我真的认为这应该通过css将图标放在右侧来处理。

于 2021-02-24T19:05:30.083 回答