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 trial

WordPress From Bootstrap to WordPress Create Bootstrap Styled Theme Templates Creating a Portfolio Single Page

Dawn Foster
Dawn Foster
1,899 Points

Confused about the direction the links provide in the prev-next functions

In this video you provided this code for the prev-next icons to cycle through all the single portfolio pieces:

<?php next_post_link( '%link', '<span class="glyphicon glyphicon-circle-arrow-left"></span>' ); ?>
<?php previous_post_link( '%link', '<span class="glyphicon glyphicon-circle-arrow-right"></span>' ); ?>

I can see that it works, but it seems counter-intuitive to me.

The next_post_link function points to the left.. but to me, the left/back arrow indicates you are wanting to go back to see the PREVIOUS item.

Same with the previous_post_link function when it points to the right.. to me, the right/forward arrow seems to indicate you are wanting to go forward to the NEXT item.

So why are the function names called exactly the opposite?? I checked in CODEX, but couldn't find anything that would explain why it appears to be the opposite of what you would expect. (Sorry if this is a stupid question.. I just want to understand!)

1 Answer

Zac Gordon
Zac Gordon
Treehouse Guest Teacher

You are correct that it seems a little counter intuitive. I feel the same way. You can change the language and direction of arrows, etc so it makes more sense for you though.

Dawn Foster
Dawn Foster
1,899 Points

Thanks Zac. I am glad that I am not alone in thinking that.

No, I won't change the arrows, because the way they appear on the page is the correct look and function in my opinion.

It was just the WP naming convention of the actual functions that doesn't make sense to me. I would have expected the NEXT_post_link function to be called PREVIOUS_post_link function because of the way it handles the direction of the post it provides when clicked on, and visa-versa.

Thanks for your quick reply