Title: Adding current category to query_posts
Last modified: August 21, 2016

---

# Adding current category to query_posts

 *  [mlol](https://wordpress.org/support/users/mlol/)
 * (@mlol)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/adding-current-category-to-query_posts/)
 * So I am reworking my category page. I want to list all of the posts in the category
   in alphabetical order and output certain things per post like custom fields etc.
 * I have The Loop working, and it displays some custom fields for each post.
 * The problem is, it sorts them by (i think most recent post) by default and I 
   want it to be title/alphabetical order. I figured out how to do this using query_post,
   but now it is querying all posts, and I just need to add “only current category”
   of the category page into query_posts. I tried defining a variable using “get_the_category”
   before the loop, but it is returning an array. Here is my current query_post:
 * query_posts(‘&order=ASC&orderby=title&’);
 * just need to add in current category to the parameters. Any suggestions?

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/adding-current-category-to-query_posts/#post-3917520)
 * [http://codex.wordpress.org/Function_Reference/query_posts#Preserving_Existing_Query_Parameters](http://codex.wordpress.org/Function_Reference/query_posts#Preserving_Existing_Query_Parameters)
 *  Thread Starter [mlol](https://wordpress.org/support/users/mlol/)
 * (@mlol)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/adding-current-category-to-query_posts/#post-3917525)
 * Well that was fast and easy, I tried searching for it but apparently not with
   the right queries. (badump chssshhhhh!)
 * I will try this after work, thank you very much! Should I use <?php wp_reset_query();?
   > before I use this? Sorry if this is very beginner, its because I am an ultra
   beginner. I dont know if changin the query is a permanent thing, or just in the
   current php file i’m working in…

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

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

 * 2 replies
 * 2 participants
 * Last reply from: [mlol](https://wordpress.org/support/users/mlol/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/adding-current-category-to-query_posts/#post-3917525)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
