Title: Get current category
Last modified: August 21, 2016

---

# Get current category

 *  [CombatPost](https://wordpress.org/support/users/combatpost/)
 * (@combatpost)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/get-current-category-1/)
 * Hi all,
 * I’m using this code to get posts by a tag, now I want to use it to get posts 
   by the current page category.
 * `$recent = new WP_Query(array( 'tag' => 'Reel', 'posts_per_page' => '4', 'offset'
   => '0' )); while($recent->have_posts()) : $recent->the_post();`
 * Does anyone have any idea how to get the current category and then what I need
   to replace tag => reel with?
 * Thanks

Viewing 1 replies (of 1 total)

 *  Thread Starter [CombatPost](https://wordpress.org/support/users/combatpost/)
 * (@combatpost)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/get-current-category-1/#post-4278806)
 * Fixed with this:
 *     ```
       <?php
       global $post;
       $category = get_the_category($post->ID);
       $category = $category[0]->cat_ID;
       $recent = new WP_Query(array( 'posts_per_page' => '4', 'offset' => 1, 'category__in' => array($category)  )); while($recent->have_posts()) : $recent->the_post();
       ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Get current category’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [CombatPost](https://wordpress.org/support/users/combatpost/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/get-current-category-1/#post-4278806)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
