Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGabriel Ward
20,222 Pointsposts per page on blog page.
I'm trying to write the code in my home.php template, so that I can display 2 posts per page, and then have links to older and newer posts. I have links at the bottom, and can click on them, but when I click on them the posts listed don't change. Here's my code,
<?php echo get_next_posts_link( "Newer posts" ); ?>
<?php echo get_previous_posts_link( "Older posts" ); ?>
Any help would be greatly appreciated.
2 Answers
Nattapol Kamolbal
15,528 PointsCheck to see if you wrap them in the loop.
michel rodrigues
Courses Plus Student 563 PointsI guess because you need to wrap it with an anchor tag ? might be obvious but can be helpful. Of course all this is assuming that this is the problem.
<a href="<?php echo get_next_posts_link(); ?>">Newer posts</a>
<a href="<?php echo get_previous_posts_link(); ?> ">Older posts</a>