Community Forums › Forums › Archived Forums › Design Tips and Tricks › how to get "older post – newer post" link in post page?
- This topic has 7 replies, 2 voices, and was last updated 10 years, 9 months ago by Brad Dalton.
-
AuthorPosts
-
July 18, 2013 at 1:04 pm #51335FabioParticipant
Hi there 🙂
What I mean is. I post a story in 20 episodes.If you are on post 14 I would like to have a link at the bottom of the post that says "older" or "newer" so that my reader can clink on it and read the previous or next episode.
At the moment I can choose the older/newer option for the home page but not from the inside of the "post page" itself if you know what I mean.
Anybody has any idea how to do that?
Thanks!!!!
http://letstalksex.netJuly 18, 2013 at 3:10 pm #51354Brad DaltonParticipantHi there Fabio
There's 2 ways to do this:
1. You can use a custom previous and next page nav links for a custom post type or category or tag(anything conditionally).
2. Or you can use category links
You'll find the 2nd code snippet links all posts in all categories so it won't link posts from one category to posts in another category.
July 18, 2013 at 3:15 pm #51355FabioParticipantHi Brad!
thanks for your reply.What's the difference between the two approaches?
Thanks a lot for your help! You always help me, I really hope 100k people get to your wpsites.net and buy everything!
July 18, 2013 at 4:06 pm #51357Brad DaltonParticipanthahahaha Thanks Fabio.
Try them out and see which one you like.
There's also some CSS for the second snippet.
.previous-post-link { float: left; } .next-post-link { float: right; text-align: right; }
July 19, 2013 at 5:40 am #51418FabioParticipantHi Brad,
I've pasted the bits of code you gave me in my theme function file, right at the bottom.Unfortunately none of them work...
The only one I had success with was this one I found on your website:
function wpsites_npp_navigation_links() {
if ( is_single ( ) ) { ?>
<?php previous_post('« « %', 'Previous', 'no'); ?>
| <?php next_post('% » » ', 'Next', 'no'); ?>
<?php
} }
/**
* @author Brad Dalton
* @learn more http://wp.me/p1lTu0-9z2
*/
add_action('genesis_after_post_content', 'wpsites_npp_navigation_links', 5 );But in this case "previous" and "next" are quite ugly-looking as you can see at the bottom of my test site: http://exclusiveskills.com/tantric-sex/
I had the same exact result on my blog.
What should I do?
Am I pasting the code in the wrong place?Thanks!
July 19, 2013 at 8:22 am #51427Brad DaltonParticipantInteresting Fabio because i use both of them on my live site which runs Genesis 2.0 HTML 5 Markup.
I think the reason is because the first code snippet doesn't include any div class for styling. It also assumes your CPT is named portfolio otherwise you will need to edit the code.
The second snippet does include a class however it uses the new HTML 5 hooks which means it won't work on themes using the old XHTML markup with old loop hooks which i did note above.
So here's the solution for you which includes the old loop hooks.
Please copy the code from the view raw link and paste it at the end of your child themes functions.php file using a text editor like Notepad++.
Let me know if this works for you please Fabio.
July 19, 2013 at 10:45 am #51456FabioParticipantThanks a lot Brad!
This works great.I also integrated your CSS tips learned here:
http://wpsites.net/web-design/add-single-post-nav-links-for-categories/in order to make it look nicer.
I'm using it on an adult subdomain of mine, so I'm not putting the link here to show you how it looks, but it looks exactly like the example in your post above.
Thanks a lot!
Also, you mentioned "Genesis 2.0 HTML 5 Markup", I thought I had the latest version of Genesis installed, maybe I don't...
Is it necessary for me to install this "Genesis 2.0 HTML 5 Markup"?Best
FabioJuly 19, 2013 at 1:11 pm #51474Brad DaltonParticipantYou can update to the latest stable version which is Genesis 2.0 RC 1 however you don't need to add HTML 5 support to your child theme unless you want to.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.