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 Pointsadding next post/previous post links to the posts in Wordpress.
I'm wanting to add links to the previous and following posts at the bottom of my post pages in my Wordpress Theme. I've had a look at the codex and am a bit lost. Don't know exactly where to start. Do I add wp_query code in functions.php? Do I add code to my single.php page, which is the template for my post pages? Thanks for any help.
3 Answers
Rich Bagley
25,869 PointsGabriel Ward
20,222 PointsHi Rich,
I'm not too worried about previous or next at the moment. I'm completely unsure how to even bring a link up at the bottom of a post's page. I'm not sure what code to add and where (either home.php or functions.php)
Gabriel Ward
20,222 PointsAlso, after all that thumbnail trouble, I'm working on trying to get a cropped version of each posts thumbnail, to display on the actual posts page. What do I have to do to make that happen? Do I need to add anything to functions.php? Or do I need to set an array along the lines of
<?php the_post_thumbnail( array (400,500, true) ); ?>
in the single.php template?
Gabriel Ward
20,222 PointsGabriel Ward
20,222 PointsI just addded
<?php next_posts_link( $label , $max_pages ); ?>
to the bottom of home.php, but it didn't work.
Rich Bagley
25,869 PointsRich Bagley
25,869 PointsHi Gabriel,
It needs to be included within the loop on a single post.
Try this (singular post not posts):
<?php previous_post_link(); ?>
-Rich
Gabriel Ward
20,222 PointsGabriel Ward
20,222 PointsOk thanks that worked. Any idea how to get rid off the << arrow? At the moment the link looks like « alrighty then (alrighty then is the name of the previous post)
Rich Bagley
25,869 PointsRich Bagley
25,869 PointsHi Gabriel,
The examples from the Codex will show how to get rid of the <<.
Hope that helps :)
-Rich
Gabriel Ward
20,222 PointsGabriel Ward
20,222 PointsThanks Rich,
If I may ask I was wondering if you might be able to help me with this question here, which I posted
https://teamtreehouse.com/forum/different-post-sizes-in-wordpress
I'm a bit confused by all the various functions and trying to get my head around the codex. Basically I'm trying to set a cropped and specific size of the image for the single.php.