wp_list_categories - 将类添加到列表项

时间:2014-06-25 14:11:53

标签: css wordpress widget wordpress-theming categories

我正在尝试设置我的wordpress类别列表,为每个li元素添加一个list-group-item类,如下所示:

<ul class="list-group">
    <li class="list-group-item cat-item cat-item-12"><a href="..." title="View all posts filed under ...">...</a></li>
    <li class="list-group-item cat-item-14"><a href="..." title="View all posts filed under ...">...</a></li>
</ul>

扩展 WP_Widget_Categories

Class GdCategoriesWidget extends WP_Widget_Categories {

function widget( $args, $instance ) {

        // Most of widget method deleted out for S/O readability.

    ?>
    <ul class="list-group">
<?php
    $cat_args['title_li'] = '';

    wp_list_categories( apply_filters( 'widget_categories_args', $cat_args ) );
?>
        </ul>

    // After Widget stuff deleted out for S/O readability

}

取消注册原件并注册我的自定义小部件

function gd_widget_registration() {
    unregister_widget('WP_Widget_Categories');
    register_widget('GdCategoriesWidget');
}
add_action('widgets_init', 'gd_widget_registration');

我遇到的问题是我无法在文档http://codex.wordpress.org/Template_Tags/wp_list_categories#Markup_and_Styling_of_Category_Lists中看到我可以覆盖应用于列表项的类。

0 个答案:

没有答案