带有自定义 link 的 Wordpress 多类别显示

Wordpress multiple category display with custom link

我正在使用 <?php the_category(); ?> 来显示我的 post 的类别。

它正在显示,但我的问题是它产生的 permalink。

类别link举个例子:http://samplesite.com/category/funpage/

我想要的是删除 link 中的类别并只生成:http://samplesite.com/funpage/

此外,我正在使用 custom post type UI 创建 post。

有人可以帮我吗?

您可以使用 get_the_category() 函数并获取该 post 的所有类别并使用循环显示。

<?php
foreach((get_the_category()) as $category) {
?>
     <a href='url you want to pass add here '><?php  echo $category->name; ?></a>       
<?php 
}
?>