Say I have a post called Hello World in WordPress and I’m directly viewing this page, how would I go about finding the category of “Hello World” and displaying it?
Leave a Reply
You must be logged in to post a comment.
Say I have a post called Hello World in WordPress and I’m directly viewing this page, how would I go about finding the category of “Hello World” and displaying it?
You must be logged in to post a comment.
Use
get_the_category()
like this:It returns a list because a post can have more than one category.
The documentation also explains how to do this from outside the loop.
You can use
which would output them in a comma separated list.
You can also do the same for tags as well:
To find the category id, category link and category name in wordpress using php, you can use below code: