Wordpress 菜单 - 图标未按照 'after' 或 wp_nav_menu 中指定的方式显示

Wordpress menu - icon doesn't show as specified in 'after' of wp_nav_menu

遇到一个需要附加字体图标的菜单。该图标在 before 中有效,但在 after 中无效:

function mobile_menu()
{
    $mobile = array(
        'theme_location' => 'mobile',
        'container'       => false,
        'container_class' => '',
        'container_id'    => '',
        'menu_class'      => '',
        'menu_id'         => '',
        'echo'            => true,
        'fallback_cb'     => false,
        'before'          => '',
        'after'           => '<span><i class="fas fa-chevron-right"></i></span>',
        'link_before'     => '',
        'link_after'      => '',
        'items_wrap'      => '<ul>%3$s</ul>',
        'depth'          => 0,
        'walker'          => new CUSTOM_Walker()
    );

    wp_nav_menu($mobile);
}

不同包装元素和无包装元素的问题仍然存在。 没有CSS或JS操作菜单​​

如何让 fontawesome 图标与 after class 一起使用?

没有人可以用上面的输入来回答这个问题。在自定义助行器中,我有以下行:

$output .= sprintf("\n <li%s>%s<a href='%s' target='%s'>%s</a>\n", $li_class, $before, $item->url, $target, $item->title, $after);

sprintf 的工作方式永远不会附加 after 伪元素。我在结束 a 标签后遗漏了一个 %s

应该是这样的:

$output .= sprintf("\n <li%s>%s<a href='%s' target='%s'>%s</a>%s\n", $li_class, $before, $item->url, $target, $item->title, $after);