How to get category id in single.php wordpress?
I need to get category id in single.php. I tried this: $cat_ID = get_query_var(‘cat’); It didn’t work. What should I use instead? 2 Answers 2 Use wp_get_post_categories() Retrieve the list of categories for a post. <?php wp_get_post_categories( $post_id, $args ) ?> Be aware that the function returns an array (of category ids) even if you … Read more