0

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...

0

1 Answer 1

0

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

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