WordPress.org

Ready to get started?Download WordPress

Forums

Simple query_posts not working (2 posts)

  1. mattyk
    Member
    Posted 1 year ago #

    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; ?>
  2. vtxyzzy
    Member
    Posted 1 year ago #

    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"); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic