Title: Array by current category
Last modified: August 21, 2016

---

# Array by current category

 *  [CombatPost](https://wordpress.org/support/users/combatpost/)
 * (@combatpost)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/array-by-current-category/)
 * Hi all,
 * I’m editing my category.php file and I’ve ran into a problem. Basically I have
   this code that I created for my Index, but I’m going to use it on the Cat page
   too.
 * Code: `<?php $recent = new WP_Query(array( 'tag' => 'Hot', 'posts_per_page' =
   > '4', 'offset' => '1' )); while($recent->have_posts()) : $recent->the_post();?
   >`
 * I’m going to need to change ‘tag => hot’ to reflect the current category page.
   So cat => current, I know that isn’t the syntax, but that’s what I’m looking 
   for.
 * Thanks

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Dave Naylor](https://wordpress.org/support/users/wpranger/)
 * (@wpranger)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/array-by-current-category/#post-4277583)
 * How about using:
 *     ```
       <?php $category = get_category( get_query_var( 'cat' ) );
              $cat_id = $category->cat_ID; ?>
       ```
   
 *  Thread Starter [CombatPost](https://wordpress.org/support/users/combatpost/)
 * (@combatpost)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/array-by-current-category/#post-4277704)
 * How would that fit in?
 * Would it be..
 *     ```
       <?php $category = get_category( get_query_var( 'cat' ) );
              $cat_id = $category->cat_ID; ?>
       ```
   
 * Then
 * `<?php $recent = new WP_Query(array( '$category', 'posts_per_page' => '4', 'offset'
   => '1' )); while($recent->have_posts()) : $recent->the_post();?>`
 * Thanks for the help
 *  Thread Starter [CombatPost](https://wordpress.org/support/users/combatpost/)
 * (@combatpost)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/array-by-current-category/#post-4277706)
 * I tried the code above but not working I’m afraid 🙁
 * _[continued at [http://wordpress.org/support/topic/get-current-category-1?replies=2](http://wordpress.org/support/topic/get-current-category-1?replies=2)]_

Viewing 3 replies - 1 through 3 (of 3 total)

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [CombatPost](https://wordpress.org/support/users/combatpost/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/array-by-current-category/#post-4277706)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
