Archived topic
Pagination and Comments
9 replies · Started by John on December 19, 2018
I want the ability to move the default wp pagination (ex: links to previous or next page) and comments form on a post to specific areas of my template using element hooks. How do I disable the out-of-box hooks and what wp functions do I need to use to solve my question?
PS I tried this several times and couldn't find a way to make this work the way I wanted. This is not a lazy post :)
Hi there,
in this topic Tom provides the code for hooking the post nav elsewhere:
This article displays the main hooks you can use, just swap accordingly:
Dave,
I'm not getting the results I want for moving the pagination where I want it to be. Below is the code from the post you mentioned with my updates to it. If you look at the example blog post (https://kelleyranaudo.com/healthy-holiday-vibes/) you will see that the pagination is above the comments area and not displaying in the proper div container with the text called "Custom pagination should go here".
hook code I am using:
So where do you want the nav to appear? Within its own separate container like the facebook comments are displayed?
I want the pagination links to appear in the their separate container called Custom pagination should go here”.
David - did my last reply makes sense?
I'm getting close. This is what I have but it has errors.
<?
add_action( 'generate_before_comments_container', 'jr_move_post_nav' );
function jr_move_post_nav() {
if ( function_exists( 'generate_content_nav' ) && is_single() ) {
previous_post_link('« « %', '', 'yes');
next_post_link('% » » ', '', 'yes');
}
}
?>
That code looks ok - what errors are you getting?
Tom - below are screen shots and the url to the actual page.
what is displayed on the page
The page nav code used in the element
page: https://kelleyranaudo.com/weekly-vibes-it-is-december/
How is the News on Blog section being added?
add_action( 'generate_before_comments_container', 'tu_move_post_navigation' );
function tu_move_post_navigation() {
if ( function_exists( 'generate_content_nav' ) && is_single() ) {
generate_content_nav( 'nav-below' );
}
}
?>
Custom pagination should go here