- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
I’ve been using this query now for a while to get post titles and excerpts outside the loop. Does anyone know if there’s a way to amend the snippet I’m using to add pagination so that after so many post excepts are shown they’d break to another page if there are any more?
$myposts = new WP_Query();
$myposts->query('cat=8&showposts=1');
if ($myposts->post_count == 0) { ?>
while ($myposts->have_posts()) : $myposts->the_post(); ?>
} ?>
Thank you!
Add the below to the end of your query:
&paged=' . get_query_var('paged')); ?>
Thanks for that, I tried adding it like this but it doesn’t work, have I inserted it in the wrong place/way?
query('cat=6&showposts=50&paged=' . get_query_var('paged')); ?>
have_posts()) : $recent->the_post(); ?>
">
(Posted on )
You might need to substitute
showposts=50
With
posts_per_page=10
Of course, you will also need to add in your previous/next page links after your endwhile;
I found a solution that seems to work nicely (I couldn’t get it to work with the other query). Here’s the code for anyone who wants to achieve the same thing.
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('cat=6&showposts=50'.'&paged='.$paged);
?>
have_posts()) : $wp_query->the_post(); ?>
- " rel="bookmark">