Title: Query Posts isnt working
Last modified: August 19, 2016

---

# Query Posts isnt working

 *  [isJohnny](https://wordpress.org/support/users/isjohnny/)
 * (@isjohnny)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/query-posts-isnt-working/)
 * In my functions.php file I have this
 *     ```
       function get_posts_page() {
   
       	global $wpdb;
       	global $query_string;
   
       		if(is_category()) {
   
       			$cat = get_query_var('cat');
       			$catx = get_category($cat);
   
       			$catname = $catx->cat_name;
   
       		}
   
       	query_posts("&post_status=publish&offset=".$_POST['off']."&category_name=".$catname);
   
        // The loop is here..
   
       }
       ```
   
 * So it’ll query_posts and change the posts depending on what category you’re in.
   The is_category() bit isn’t working at all (I tried echoing $catname and nothing
   happened). Any ideas why? Do i need to add an action to this function to make
   it work or am I missing a global variable, or what?

The topic ‘Query Posts isnt working’ is closed to new replies.

## Tags

 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)
 * [the-loop](https://wordpress.org/support/topic-tag/the-loop/)

 * 0 replies
 * 1 participant
 * Last reply from: [isJohnny](https://wordpress.org/support/users/isjohnny/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/query-posts-isnt-working/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
