Title: Simple query_posts not working
Last modified: August 20, 2016

---

# Simple query_posts not working

 *  [mattyk](https://wordpress.org/support/users/mattyk/)
 * (@mattyk)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/simple-query_posts-not-working/)
 * Hi There, can anyone help me understand as to why this isn’t working? It seems
   simple enough and is what the codex suggests but it has no affect on what categories
   show – Much appreciated
 *     ```
       <?php query_posts($query_string . "&cat=-1"); ?>
       			<?php if ( have_posts() ) : ?>
       				<?php while ( have_posts() ) : the_post(); ?>
       					<?php
       						get_template_part( 'content', get_post_format() );
       					?>
   
       				<?php endwhile; ?>
   
       				<?php matt_content_nav( 'nav-below' ); ?>
   
       			<?php else : ?>
       				<?php get_template_part( 'no-results', 'index' ); ?>
       			<?php endif; ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/simple-query_posts-not-working/#post-3323154)
 * Are you sure that your code is being executed? If so, try declaring $query_string
   as a global:
 *     ```
       <?php global $query_string;
        query_posts($query_string . "&cat=-1"); ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Simple query_posts not working’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/simple-query_posts-not-working/#post-3323154)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
