admin管理员组

文章数量:1404458

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

1 Answer 1

Reset to default 1

First 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).

本文标签: categoriesGet post category as a separate string and url