I need to get any post category id from the post id(Not for current) Post. How can i ?


  • i used this code . but i got i array is blank global $post; $category_detail=get_the_category( $post->ID ); Mar 18, 2014 at 7:48

2 Answers 2


You can try this code for getting category id from post id:

global $post;
$category_detail=get_the_category( $post->ID );

Take a look at wp_get_post_categories function. It returns an array of categories' ID for specific post.

$post_categories = wp_get_post_categories( $post_id );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.