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 ); Commented 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 you have read our privacy policy.

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