下面是我如何操作\\u category()模板标记的输出。
功能。php:
function add_post_category_list_attrs($the_list) {
$list_id = "post-categories-id";
$category_title = __("Categories");
$list_trigger = sprintf(\'<a href="#" data-dropdown="%s" aria-controls="%s" aria-expanded="false" class="cat-list-trigger">%s</a>\',
$list_id, $list_id, $category_title);
$the_list = substr_replace($the_list, $list_trigger, 0 ,0);
$the_list = str_replace(\'<ul class="post-categories">\',
sprintf(\'<ul class="f-dropdown" id="%s" data-dropdown-content aria-hidden="true" tabindex="-1">\',
$list_id),
$the_list);
return $the_list;
}
if( ! is_admin() ){
add_filter(\'the_category\', \'add_post_category_list_attrs\');
}