Limiting query_posts to 1, regardless of sticky post?

$GLOBALS['wp_query']->found_posts will give you the number of posts.

$GLOBALS['wp_query']->posts is an array with all the posts found.

So instead of while ( have_posts() ) : the_post(); use:

setup_postdata( $GLOBALS['wp_query']->posts[0] );
get_template_part( 'content', 'super' );

This way you don’t run through all post, you really just use one.

And please read When should you use WP_Query vs query_posts() vs get_posts()?

Leave a Comment