- Envato Staff
- Reviewer
- Community Moderator
- Venezuela
- Has been a member for 4-5 years
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Microlancer Beta Tester
- Sold between 10 000 and 50 000 dollars
- Exclusive Author
Hi guys,
I’m having a tiny issue with WordPress that I can’t figure out… I just have 7 posts in the Blog Template page and I’m using this code – http://pastie.org/860191
I use query_post to show only the latest 4 posts from the category 6 but when I click the Next Posts link it shows the same 4 posts (not the rest of the posts) and the weird thing is that it shows this path blog/page/2 but I can’t see the others posts.
Here’s the page code http://pastie.org/860191 , there’s any errors in it? Am I missing something? 
- Bought between 10 and 49 items
- Exclusive Author
- Has been a member for 5-6 years
- Referred between 1 and 9 users
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Sold between 5 000 and 10 000 dollars
- Uruguay
when you use query_posts, you need to hold the original query on a variable, then use a temp variable to hold the new query, and at the end, restore the original query…. or, use a reset query at the end: wp_reset_query();
Just like this:
<?php //The Query
query_posts('posts_per_page=5');
//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();
..
endwhile; else:
..
endif;
//Reset Query
wp_reset_query();
?>
Maybe is that.
Here:
Shouldn’t the ‘navigation’ div with next/previous posts link be before endwhile?
You need to declare that the template is paged. See http://weblogtoolscollection.com/archives/2008/04/19/paging-and-custom-wordpress-loops/
this uses WP_query though but it can give you the overall idea.
- Bought between 10 and 49 items
- Exclusive Author
- Has been a member for 5-6 years
- Referred between 1 and 9 users
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Sold between 5 000 and 10 000 dollars
- Uruguay
also you should take this into consideration:
http://theodin.co.uk/blog/design/wordpress-pagination-wppagenavi-queryposts.html
happend to me once.
- Envato Staff
- Reviewer
- Community Moderator
- Venezuela
- Has been a member for 4-5 years
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Microlancer Beta Tester
- Sold between 10 000 and 50 000 dollars
- Exclusive Author
Thanks a lot guys, I’ll give it a shot. 
- Envato Staff
- Reviewer
- Community Moderator
- Venezuela
- Has been a member for 4-5 years
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Microlancer Beta Tester
- Sold between 10 000 and 50 000 dollars
- Exclusive Author
digitalimpact, arriba, headset thanks a lot guys this tutorial works like a charm
you guys rock! thanks.
@Headset I’ll use WP_Query now 
digitalimpact, arriba, headset thanks a lot guys this tutorial works like a charmyou guys rock! thanks. @Headset I’ll use WP_Query now
![]()
Glad to help mate
– keep up the great work!
