How to get Category Id from Post Id ? olatechproMarch 17, 20230 Views I need to get any post category id from the post id(Not for current) Post. How can i ? Thanks Post Views: 0 Related postsGet rid of this Strict Standards warningWooCommerce: get_current_screen not working with multi languageCan’t login on WordPressForce HTTPS using .htaccess – stuck in redirect loopWordPress: Ajax not working to insert, query and result dataHow Can I pass an image file to wp_handle_upload?
You can try this code for getting category id from post id: global $post; $category_detail=get_the_category( $post->ID ); Log in to Reply
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 ); Log in to Reply
You can try this code for getting category id from post id:
Take a look at wp_get_post_categories function. It returns an array of categories’ ID for specific post.