ayumee
9/22/2017 - 8:06 PM

Show post categories list with bootstrap style

<?php
    $categories = wp_list_categories('title_li=&depth=1&echo=0');
    $categories = preg_replace('@\<li([^>]*)>\<a([^>]*)>(.*?)\<\/a>@i', '<a$1$2>$3</a>', $categories);
    $categories = str_replace('cat-item', 'list-group-item list-group-item-action', $categories);
    $categories = str_replace('current-cat', 'active', $categories);
    if($categories){
        echo $categories;
    }
?>