我正在尝试设置我的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中看到我可以覆盖应用于列表项的类。