Archived topic
How Do I Create Next - Previous Article Links
9 replies · Started by RJ on October 21, 2019
Hey there,
I must be blind today because I can't for the life of me figure out how to create/show Next and Previous article links at the bottom of each blog post.
I'd love it if they could look something like this:
https://www.screencast.com/t/lhPoMCXgdfy
Could you let me know? Many thanks.
Robin
Hi there,
in Customizer > Layout > Blog --> Select Singles Tab and then check: Display post navigation
Once thats active try this CSS:
.nav-previous .prev:before {
content: 'Previous Article';
}
.nav-next .next:before {
content: 'Next Article';
}
.nav-previous .prev:before,
.nav-next .next:before {
width: auto;
display: block;
font-family: inherit;
text-align: left;
margin-right: 0;
margin-bottom: 0.5em;
margin-top: 1.5em;
}
@media (min-width: 769px) {
.nav-next .next:before {
text-align: right;
}
.post-navigation {
display: flex;
justify-content: space-between;
}
}
Thanks, David. That worked. Cheers - Robin
Glad to be of help - looks great.
Is there a way to make the next/previous article like only show articles within a specific category.
Example: Visitor is viewing an article in the 'Recipe' category. I only want Next/Previous articles to be from the 'Recipe' category.
Likewise, if someone is looking at a video in the 'Video' category, I only want Next/Previous articles to be from the 'Video' category.
Is there a way to do this?
Cheers.
Hi Leo,
I have added this code and activated it:
add_filter( 'generate_category_post_navigation', 'article_navigation_category_specific' );
function example_function_name()
{
return 'Your new value';
}
Seems the full code doesn't show. Here's a screenshot - https://www.screencast.com/t/Cmp4XTWY
And it doesn't seem to work. Still shows articles from other categories.
Something like this may be better: https://generatepress.com/forums/topic/single-post-lazy-loading-with-slug-and-title-update/#post-1359534
That worked, Tom. Many thanks.
You're welcome :)