I tried to add a button to a the menu items which have children with the following code:
function add_button( $output, $item, $depth, $args ){
if (in_array("menu-item-has-children", $item->classes)) {
$output .='<button type="button" class="btn btn-circle"><i class="fa fa-chevron-circle-down"></i> </button>';
}
return $output;
}
add_filter( 'walker_nav_menu_start_el', 'add_button',10,4);
The problem is that are in the next row after the item, but i want them to appear right beside the item. How can I do that?
I tried to add a button to a the menu items which have children with the following code:
function add_button( $output, $item, $depth, $args ){
if (in_array("menu-item-has-children", $item->classes)) {
$output .='<button type="button" class="btn btn-circle"><i class="fa fa-chevron-circle-down"></i> </button>';
}
return $output;
}
add_filter( 'walker_nav_menu_start_el', 'add_button',10,4);
The problem is that are in the next row after the item, but i want them to appear right beside the item. How can I do that?
Share Improve this question asked Jul 25, 2019 at 11:24 xxrayxxray 11 Answer
Reset to default 0Please try something like this.
function add_button( $output, $item, $depth, $args ){
if (in_array("menu-item-has-children", $item->classes)) {
$output ='<button type="button" class="btn btn-circle">
<i class="fa fa-chevron-circle-down"></i>
</button>'.$output;
}
return $output;
}
add_filter( 'walker_nav_menu_start_el', 'add_button',10,4);