Title: problems getting category
Last modified: February 21, 2017

---

# problems getting category

 *  Resolved [hyacinthus](https://wordpress.org/support/users/hyacinthus/)
 * (@hyacinthus)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/problems-getting-category/)
 * I want to get the category of a post. I’ve tried using get_the_category_by_ID
   without success even though I know I’m using the correct ID. The function does
   not return the string I expect. Doesn’t seem like it should be difficult to get
   the category name of a post.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/problems-getting-category/#post-8828197)
 * [https://developer.wordpress.org/reference/functions/get_the_category/](https://developer.wordpress.org/reference/functions/get_the_category/)
 * needs to be used in the loop, unless you have the ID of the post;
 * posts can have more than one category – to get only one, see [https://developer.wordpress.org/reference/functions/get_the_category/#comment-307](https://developer.wordpress.org/reference/functions/get_the_category/#comment-307)
 *  [lelandf](https://wordpress.org/support/users/lelandf/)
 * (@lelandf)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/problems-getting-category/#post-8828318)
 * It’s important to note the ID in get_the_category_by_ID refers to the category
   ID, not the post ID. The function accepts no other parameters besides category
   ID, so it’s not really useful if you want to get the category of a post.
 * The above post explains what you need to do. 🙂
 *  Thread Starter [hyacinthus](https://wordpress.org/support/users/hyacinthus/)
 * (@hyacinthus)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/problems-getting-category/#post-8830128)
 * Thanks. I had missed that by_ID uses the category ID. Using the get_the_category
   works for me now.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘problems getting category’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 3 participants
 * Last reply from: [hyacinthus](https://wordpress.org/support/users/hyacinthus/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/problems-getting-category/#post-8830128)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
