#Customize and display links to previous and next post, from a single post
This snippet is for displaying and customizing the links to previous and next posts, for single post entries within the Genesis Framework.
Normally the links to the previous and next post are displayed in the entry footer as the title of the next and previous posts. I wanted to customize the function to swap the link order so that the newest article was accessible from the link on the left and the previous article was accessible form the link on the right, to better navigate posts in an ascending order. I also wanted to add the text "Previous Post" and "next Post" above the linked post titles for better clarification. See the comment in the code for more detail.
For additional customizable permeates, see the codex links under References.
Normally single post navigation is added via:
//* Add post navigation
add_action( 'genesis_after_loop', 'genesis_prev_next_post_nav' );
#Source:
Find the source file in the Genesis theme under: genesis/lib/structure/post.php
/**
* Display links to previous and next post, from a single post.
*
* @since 1.5.1
*
* @return null Return early if not a post.
*/
function genesis_prev_next_post_nav() {
if ( ! is_singular( 'post' ) )
return;
genesis_markup( array(
'html5' => '<div %s>',
'xhtml' => '<div class="navigation">',
'context' => 'adjacent-entry-pagination',
) );
echo '<div class="pagination-previous alignleft">';
previous_post_link();
echo '</div>';
echo '<div class="pagination-next alignright">';
next_post_link();
echo '</div>';
echo '</div>';
}
#Refrance:
Notes:
- http://my.studiopress.com/snippets/entry-content/
- http://genesis.wp-a2z.org/oik_api/genesis_prev_next_post_nav/
Codex: