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
Add a comment  | 

2 Answers 2

Reset to default 0

You 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