Title: Help with category.php loop
Last modified: August 19, 2016

---

# Help with category.php loop

 *  [larsbachmann](https://wordpress.org/support/users/larsbachmann/)
 * (@larsbachmann)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/help-with-categoryphp-loop/)
 * Hi
 * Can anyone help me with my category.php theme file.
 * I want to make a loop that shows future post from the specific category. So the
   only thing that should be different is that my category.php have to show future
   post instead of publish post.
 * I manage to do that with my index.php, but i can’t make it work with categories.
 * My index.php looks like this:
 * <?php
    $my_query = new WP_Query(‘post_status=future&order=ASC’); ?>
 * <?php
    if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query-
   >the_post(); $do_not_duplicate = $post->ID; ?>
 * Thanks
    Lars

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

 *  Thread Starter [larsbachmann](https://wordpress.org/support/users/larsbachmann/)
 * (@larsbachmann)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/help-with-categoryphp-loop/#post-1476190)
 * BTW. If i use the same loop in category.php, it will show future post from all
   categorys, and not just the category you have choosen.
 * My permalinks is set to: /%postname%.html
 *  [Luke Rumley](https://wordpress.org/support/users/lukerumley/)
 * (@lukerumley)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/help-with-categoryphp-loop/#post-1476193)
 * Never tried the “future” thing, but I would guess that it works like many other
   WP functions, and that you could add &category=1 to limit it to posts from category
   ID #1. &category_name=ABCD should work too.
 * Looks like this might be another way of doing the same thing: [http://codex.wordpress.org/Template_Tags/get_posts](http://codex.wordpress.org/Template_Tags/get_posts)
 *  Thread Starter [larsbachmann](https://wordpress.org/support/users/larsbachmann/)
 * (@larsbachmann)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/help-with-categoryphp-loop/#post-1476196)
 * Hi again
 * I manage to solved it like this:
 * <?php
    global $query_string; query_posts($query_string . “&order=ASC&post_status
   =future”); ?>
 * <?php while (have_posts()) : the_post(); ?>
 *  [Luke Rumley](https://wordpress.org/support/users/lukerumley/)
 * (@lukerumley)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/help-with-categoryphp-loop/#post-1476252)
 * Ah…didn’t realize a $query_string already existed. Good work!
 *  [amogle](https://wordpress.org/support/users/amogle/)
 * (@amogle)
 * [16 years ago](https://wordpress.org/support/topic/help-with-categoryphp-loop/#post-1476493)
 * I too was having a very similar problem. Your solution has fixed my issue. Thank
   you so much.
 * I was having trouble using showposts=1 (or any other query) in my category.php
   loop. It was then calling up the wrong category. $query_string works like a charm.
 * While I am very greatful that this works, I do not know why it works. Any ideas?

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

The topic ‘Help with category.php loop’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)

 * 5 replies
 * 3 participants
 * Last reply from: [amogle](https://wordpress.org/support/users/amogle/)
 * Last activity: [16 years ago](https://wordpress.org/support/topic/help-with-categoryphp-loop/#post-1476493)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
