如何在wordpress中显示没有li标签的类别?
How to show categories without li tags in wordpress?
我需要一些有关 wordpress 功能的帮助 Wp_list_categories()
我想在标签 <div>
内显示类别链接,如下所示:
<div class="myclass">
<a>a category</a>
</div>
如果我使用 wp_list_categories(),我会得到包含在 li 标签中的类别链接,这些链接还会在每个类别之前显示项目符号 ◦。
不知道有没有这样的方法:
wp_get_archives('format=custom type=monthly &before=<div class="voices">&after=</div>');
这给了我:
<div class="voices">
<a>something</a>
</div>
您应该将 titie_li
和 style
属性添加到 wp_list_categories
,如以下代码:
wp_list_categories(array('title_li' => false, 'style' => false));
您可以使用 wp_get_post_categories(): https://developer.wordpress.org/reference/functions/wp_get_post_categories/
示例:
<?php
$categories = wp_get_post_categories(get_the_ID());
echo '<div class="voices">';
foreach($categories as $category){
echo '<a>' . get_cat_name($category) . '</a>';
}
echo '</div>';
?>
我需要一些有关 wordpress 功能的帮助 Wp_list_categories()
我想在标签 <div>
内显示类别链接,如下所示:
<div class="myclass">
<a>a category</a>
</div>
如果我使用 wp_list_categories(),我会得到包含在 li 标签中的类别链接,这些链接还会在每个类别之前显示项目符号 ◦。
不知道有没有这样的方法:
wp_get_archives('format=custom type=monthly &before=<div class="voices">&after=</div>');
这给了我:
<div class="voices">
<a>something</a>
</div>
您应该将 titie_li
和 style
属性添加到 wp_list_categories
,如以下代码:
wp_list_categories(array('title_li' => false, 'style' => false));
您可以使用 wp_get_post_categories(): https://developer.wordpress.org/reference/functions/wp_get_post_categories/
示例:
<?php
$categories = wp_get_post_categories(get_the_ID());
echo '<div class="voices">';
foreach($categories as $category){
echo '<a>' . get_cat_name($category) . '</a>';
}
echo '</div>';
?>