admin管理员组文章数量:1122832
for example : I have a Post Name computer and electronics and this post consist of two category 1.LED displays 2.Mobiles , now i want to display post = computer and electronics with it's specific categories.
for example : I have a Post Name computer and electronics and this post consist of two category 1.LED displays 2.Mobiles , now i want to display post = computer and electronics with it's specific categories.
Share Improve this question edited Oct 19, 2016 at 16:11 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Oct 19, 2016 at 6:39 Govind JangidGovind Jangid 311 silver badge6 bronze badges 1- Do you have custom taxonomy category ? – Pavel8289 Commented Jan 6, 2023 at 15:06
2 Answers
Reset to default 0You can use single_cat_title function to get category's name.
Useful for category template files for displaying the category page title. The prefix does not automatically place a space between the prefix, so if there should be a space, the parameter value will need to have it at the end.
for that purpose you need to use get_the_category($id) function, which accept the post id as parameter and return a list of terms object assigned to the passed post id, you can refer to this url to learn more.
https://developer.wordpress.org/reference/functions/get_the_category/
本文标签: how to display categories for a specific post
版权声明:本文标题:how to display categories for a specific post? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736293336a1929125.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论