Reputation: 1
I'm trying to hack a WordPress Theme that uses WP_Query for a "Recent Posts" widget. Currently it is limited to return only a specific Category, while I'd like it to return a limited number of posts from all categories. I have tried and succeeded at this before with other Plugins/Themes. In this case it doesn't work, irrespective of what change I try to implement, I get 4000+ posts in the query.
<?php $the_query = new WP_Query('cat='.$category.'&showposts='.$postnum);
while ($the_query->have_posts()) : $the_query->the_post();?>
What could be the common culprit of not having showposts or post_per_page working correctly as a limiter?
Upvotes: 0
Views: 1560
Reputation: 916
are you able to get a correct output from your variable $postnum ?
also try using this
$args = array('category_name' => 'my-category-slug', 'posts_per_page' => 3);
<?php
query_posts( $args );
while ( have_posts() ) : the_post();
echo 'content';
endwhile;
wp_reset_query();
?>
Upvotes: 1