我已经连接T5_Nav_Menu_Walker到我的WP网站。https://gist.github.com/thefuxia/1053467
我希望定制我的WP菜单,使其能够通过FontAwesome类从want添加图标。截图:显示
但是当我在菜单中添加CSS类时,在HTML代码中没有输出,因为我使用t5_nav_walker。我怎样才能在这个wordpress中添加图标?此游行者的Php代码:
';
// $output .= 'current ? ' class="current"':'').'>';
$attributes = 'class="app-menu__item"';
! empty ( $item->attr_title )
// Avoid redundant titles
and $item->attr_title !== $item->title
and $attributes .= ' title="' . esc_attr( $item->attr_title ) .'"';
! empty ( $item->url )
and $attributes .= ' href="' . esc_attr( $item->url ) .'"';
$attributes = trim( $attributes );
$title = apply_filters( 'the_title', $item->title, $item->ID );
$item_output = "$args->before$args->link_before$title"
. "$args->link_after$args->after";
// Since $output is called by reference we don't need to return anything.
$output .= apply_filters(
'walker_nav_menu_start_el'
, $item_output
, $item
, $depth
, $args
);
}
/**
* @see Walker::start_lvl()
*
* @param string $output Passed by reference. Used to append additional content.
* @return void
*/
public function start_lvl( &$output )
{
$output .= '';
}
/**
* @see Walker::end_lvl()
*
* @param string $output Passed by reference. Used to append additional content.
* @return void
*/
public function end_lvl( &$output )
{
$output .= '';
}
/**
* @see Walker::end_el()
*
* @param string $output Passed by reference. Used to append additional content.
* @return void
*/
function end_el( &$output )
{
$output .= '';
}
}发布于 2018-02-07 09:08:00
您需要为菜单项创建其他字段。因为如果要使用类字段,则会阻止向链接中添加其他类。但是如果可以的话-在链接标题之前创建。@Dilip Gupta给了你解决方案。
发布于 2018-02-07 08:26:33
看,您需要更新您的$item_output变量。方阵输出此格式的图标。
您需要像这样在您的中添加这个。
$item_output = "$args->before"
. ""
. "$args->link_before"
. ""
. "$title"
. ""
. "$args->link_after"
. "$args->after";$variable_which_stores_fontawesomme_value应该等于fa fa-angle-right。
https://wordpress.stackexchange.com/questions/293365
复制相似问题