Wordpress多个类别显示与自定义链接

问题描述 投票:1回答:1

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

它显示但我的问题是它产生的固定链接。

类别链接例如:http://samplesite.com/category/funpage/

我想要的是删除链接中的类别,只产生:http://samplesite.com/funpage/

另外,我正在使用custom post type UI创建帖子。

有人可以帮我吗?

wordpress categories
1个回答
0
投票

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

<?php
foreach((get_the_category()) as $category) {
?>
     <a href='url you want to pass add here '><?php  echo $category->name; ?></a>       
<?php 
}
?>
© www.soinside.com 2019 - 2024. All rights reserved.