Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to add numeric archive pagination to single post pages
Tagged: archive pagination, links, navigation, single page
- This topic has 13 replies, 2 voices, and was last updated 8 years, 11 months ago by Carla the Moose.
-
AuthorPosts
-
July 6, 2015 at 2:17 pm #158545Carla the MooseMember
Hi there,
My site is not live yet, but I am using the most recent version of Genesis and WordPress and am hoping you can still help me. The child theme I am using is a basic one I created based on Genesis.
On my homepage I was able to easily set up numeric pagination at the bottom of the page. I only display one post on each page, and it lets users navigate smoothly. This is not plugin.
When I click on a blog post title, it takes me to the single post page for that title. There isn't any navigation. I would like to use the exact same navigation for these single post pages, but I'm not sure how.
I thought this would be a simple matter of adding is_single to the functions code for the archive pagination, but I'm not sure what to use. Can you please help with this?
Thank you.
July 6, 2015 at 2:18 pm #158547Carla the MooseMemberI should add, I do not want to use a plugin for this.
July 6, 2015 at 3:12 pm #158552pxfortiParticipantThe numeric nav doesn't make sense for single posts. You'd want to use Previous / Next for previous next post.
For formatting of previous next, see this page: https://codex.wordpress.org/Next_and_Previous_Links
To add previous next to single posts, add the following code to the end of your functions.php file:
add_action( 'genesis_after_comments', 'genesis_prev_next_post_nav', 2 );
Note: to change the location of the prev/next links, change the action hook; eg, code above adds to genesis_after_comments.
See the following url for other genesis hooks: http://my.studiopress.com/docs/hook-reference/
writeNowDesign
WordPress and Ecommerce Website DesignJuly 6, 2015 at 3:47 pm #158554Carla the MooseMemberThank you.
Since I only have one post on each page, including the homepage of my website, does it make sense to only use single post archive pages for my entire website? It seems silly that people have to click through to the single post page to get the permalink if needed.
So the homepage would be the most recent single post entry.
Is there any reason I should keep it as it is, a standard blog with permalink post titles that take readers to the single post page?
I've often wondered about this.
July 6, 2015 at 6:20 pm #158591pxfortiParticipantWhy do you show only one post on the blog page? You're right, the user has to do a lot of clicking to see what's there. Seems like it would be more user friendly to show 5 or 10 posts per page with the numeric paging system and then maybe use the previous /next code for single posts.
writeNowDesign
WordPress and Ecommerce Website DesignSeptember 21, 2015 at 4:27 pm #166261Carla the MooseMemberIt's been a few months since I asked this question.
I'm now ready to finish my website and launch it tomorrow. I add the code snippet to my functions file and changed the hook to genesis_entry_footer. Even without the changed hook, my single post pages are not showing the previous/next pagination links.
Any suggestions on what to do? I've been researching this all day. It seems like a simple task, but for some reason I can't find any help.
My website is not live. I'm running the most recent version of Genesis with my own theme.
Thank you!!
September 21, 2015 at 4:31 pm #166264Carla the MooseMemberI believe the WordPress codex is saying the previous/next code was created for non-permalink navigation.
The code snippet you gave me doesn't say to put it on the permalink pages. This is my last task before launching tomorrow, so I'll play around and learn as much as I can.
Please let me know if you can help me understand how this works better. Thank you!
ETA: I'm learning! I'm learning! I'm making sense of the codex you linked to earlier. So let's see what needs to be done to make this display on my permalink pages. :o)))
September 21, 2015 at 4:38 pm #166266Carla the MooseMemberAck!
So I managed to make sense of the codex for this, only to scroll down a bit further and see 'Deprecated' in a red box surrounding this:
previous_post_link() and next_post_link()
The snippet you gave me is just for Genesis, but it's not working. And the WordPress solution isn't an option anymore.
This is one of those situations where I needed to ask the right question to find my answer, but I'm not sure what to ask!
:o)))
September 21, 2015 at 7:20 pm #166279pxfortiParticipantTry this:
function wnd_navigation_links() { ?> <div class="adjacent-entry-pagination pagination"><div class="pagination-previous alignleft"><?php previous_post('« %', 'Previous', 'no');?> </div><div class="pagination-next alignright"><?php next_post('% » ', 'Next', 'no'); ?> </div></div> <?php } add_action('genesis_entry_footer', 'wnd_navigation_links', 5 );
writeNowDesign
WordPress and Ecommerce Website DesignSeptember 21, 2015 at 8:02 pm #166282Carla the MooseMemberWell, just like that it works!!
Thank you SO much. Maybe folks don't feel permalink pages should have navigation links. I don't think any of the StudioPress themes include them.
This is just me being a lone ranger, I guess. But when I land on a single post page, I tend to feel stuck if I don't have a way to navigate to more content. It seems like a missed opportunity to put more material in front of people.
I'm so very grateful to you. :o)))
September 21, 2015 at 8:03 pm #166284pxfortiParticipantYou're welcome. And I agree with you; I link to have a previous / next link on the pages. I think that might encourage people to read more posts.
writeNowDesign
WordPress and Ecommerce Website DesignSeptember 21, 2015 at 8:14 pm #166289Carla the MooseMemberI just need to limit it so it doesn't display on the main blog homepage, since the links are for permalink navigation.
And 'is single' something or other statement should do that for me.
:o)))
September 21, 2015 at 8:18 pm #166290pxfortiParticipanttry this:
function wnd_navigation_links() {
if (!is_single())
return; ?>
<div class="adjacent-entry-pagination pagination"><div class="pagination-previous alignleft"><?php
previous_post('« %', 'Previous', 'no');?>
</div><div class="pagination-next alignright"><?php
next_post('% » ', 'Next', 'no'); ?>
</div></div> <?php
}add_action('genesis_entry_footer', 'wnd_navigation_links', 5 );
writeNowDesign
WordPress and Ecommerce Website DesignSeptember 22, 2015 at 1:35 am #166301Carla the MooseMemberHere's how I was able to get it to work. Thanks so much for your help. This has puzzled me for a good long while.
add_action('genesis_after_endwhile', 'wnd_navigation_links', 5 ); function wnd_navigation_links() { if ( !is_home() || is_single() ) { ?> <div class="adjacent-entry-pagination pagination"><div class="pagination-previous alignleft"><?php previous_post('« %', 'Older', 'no');?> </div><div class="pagination-next alignright"><?php next_post('% » ', 'Newer', 'no'); ?> </div></div> <?php }}
-
AuthorPosts
- The topic ‘How to add numeric archive pagination to single post pages’ is closed to new replies.