No matter what, I CANNOT figure out why WP_Query pulls in all posts, and completely ignores posts_per_page
…
I only want to show one post.
<?php
$args = array(
'post_type' => 'post',
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => -1
);
// The Query
$the_query = new WP_Query( $args );
// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
?>
<div style="padding: 15px;">
<div class="grid_4 alpha">image</div>
<div class="grid_7 omega">
<?php the_excerpt(); ?>
</div>
</div>
<div style="clear: both;"></div>
<div style="height: 33px; background-color: #5ba4d8; position: relative;">
<div style="width: 300px; line-height: 33px;"><?php the_title(); ?></div>
<a href="" style="position: absolute; right: 0; top: 0;"><span class="nav-blog-next"></span></a>
</div>
<?php
endwhile;
// Reset Post Data
wp_reset_postdata();
?>
Change
posts_per_page
to1
only, not-1
.Like this:
'posts_per_page' => 1
-1
means all.From your question title, it sounds like you are trying to only pull one single post. The problem is that you have passed -1 to posts_per_page, which equates tells the query to pull in every single post.
Use: