Add button to menu item at the same row

I tried to add a button to a the menu items which have children with the following code:function add_button( $output, $i

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 1
Add a comment  | 

1 Answer 1

Reset to default 0

Please 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);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745296738a4621186.html

相关推荐

  • Add button to menu item at the same row

    I tried to add a button to a the menu items which have children with the following code:function add_button( $output, $i

    9小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信