Why wordpress custom category_walker doesn’t accept style from start_lvl

I want to have custom category displayed on my site but for that i have to use custom walker to change output of the categories. For some reason the start_lvl doesn’t get applied style.

What i want is to replace default wordpress category listing

Read More
<ul>
   <li> cat name</li>
</ul>

with my own custom listing as a group of buttons in bootstrap style

<div class="btn-group>
   <button>cat name </button>
</div>

but the walker kinda skip adding btn-group div so with my walker class i get output like

<button> cat name</button>
<button> cat name</button>

is there something i am missing in my walker class?

class Walker_Simple_Example extends Walker_Category {  

function start_lvl(&$output, $depth=0, $args=array()) {
    $output .= '<div class="btn-group tiptip">';  
}

function end_lvl(&$output, $depth=0, $args=array()) {
    $output .= '</div>';  
}

function start_el(&$output, $item, $depth=0, $args=array()) {
    $output .= '<a href="'.get_term_link($item).'" type="button" class="btn btn-default" data-placement="bottom" data-tooltip="tooltip" data-container="body" data-original-title="'.esc_attr( $item->description ).'"><i class="fa fa-'.esc_attr( $item->slug ).'"></i>';
}

function end_el(&$output, $item, $depth=0, $args=array()) {  
    $output .= '</a>';  
}
}

Related posts

Leave a Reply