Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This question already has an answer here:

I'm trying to use the code from this page:

Display Blog Posts on any Page (with navigation) http://digwp.com/2013/01/display-blog-posts-on-page-with-navigation/

My goal is to make pages that display the posts from one category only. I'd also like to limit the number of posts per page to 5 and have pagination links at the bottom.

This will display the first 5 posts form all categories and paginate them:

<?php // Display blog posts on any page @ http://m0n.co/l
$temp = $wp_query; $wp_query= null;
$wp_query = new WP_Query(); $wp_query->query('showposts=5' . '&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post(); ?> 

However when I try to add the category in like this:

<?php // Display blog posts on any page @ http://m0n.co/l
$temp = $wp_query; $wp_query= null;
$wp_query = new WP_Query(); $wp_query->query('cat=61' , 'showposts=5' . '&paged='.    $paged);
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>

I get more than 5 posts on my page and no pagination...

share|improve this question
add comment

marked as duplicate by toscho Jun 14 '13 at 19:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

up vote 0 down vote accepted

your string concatenation is broken. join parts of a string with ., not a comma, and separate arguments with an ampersand.

$wp_query->query('cat=61&showposts=5&paged=' . $paged);
share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.