I need to figure out how to get post category as a string and link, both separate from each other. So the return would be something like:
Uncategorized
however both should be separate, because I need to put them in different parts of my markup.
I need to figure out how to get post category as a string and link, both separate from each other. So the return would be something like:
Uncategorized
http://link-to-the-category
however both should be separate, because I need to put them in different parts of my markup.
Share Improve this question asked Apr 22, 2013 at 11:41 IljaIlja 1533 silver badges14 bronze badges 1- review codex.wordpress/Function_Reference/get_the_category – Michael Commented Apr 22, 2013 at 12:53
1 Answer
Reset to default 1First you have to find the category ID, which can be done easily with the function get_the_category()
.
To get the slug, use: $catID = get_the_category(); $catSlug = $catID->slug
.
To get the link: $catLink = get_category_link($catID)
.