This code enables you to reposition the single post navigation links in Genesis to any hook position.
This post also includes the code to modify the default single post navigation.
You can add the links several ways:
add_action( 'genesis_entry_footer', 'genesis_prev_next_post_nav' );
Or like this:
add_action( 'genesis_before_while', 'hook_genesis_prev_next_post_nav' );
function hook_genesis_prev_next_post_nav() {
if ( is_singular( 'post' ) ) {
genesis_prev_next_post_nav();
}
}
If you need to modify the default single post navigation, you can using this code:
add_action( 'genesis_entry_footer', 'your_function' );
function your_function() {
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>';
}
Here’s an example of the above code where the 3rd parameter in the functions for the next and previous post links have been modified so only single posts within the same category are linked:
add_action( 'genesis_entry_footer', 'custom_single_nav' );
function custom_single_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('%link', '%title', TRUE);
echo '</div>';
echo '<div class="pagination-next alignright">';
next_post_link('%link', '%title', TRUE);
echo '</div>';
echo '</div>';
}
You can also reposition the links using code like this:
add_post_type_support( 'post', 'reposition-post-nav' );
add_action( 'genesis_after_entry', 'reposition_post_nav' );
function reposition_post_nav() {
if ( ! is_singular() || ! post_type_supports( get_post_type(), 'reposition-post-nav' ) ) {
return;
}
genesis_markup( array(
'open' => '<div %s>',
'context' => 'adjacent-entry-pagination',
) );
echo '<div class="pagination-previous alignleft">';
previous_post_link( '%link', '« Previous Page' );
echo '</div>';
echo '<div class="pagination-next alignright">';
next_post_link( '%link', 'Next Page »' );
echo '</div>';
genesis_markup( array(
'close' => '</div>',
'context' => 'adjacent-entry-pagination',
) );
}
Modify Single Post Navigation Function #
You can modify the following code for use in your genesis child theme.
Change the code within the single_post_adjacent_entry_nav_genesis function for usage in your child themes functions file or single.php template file.
The code comes from the post.php file inside genesis.
Was This Tutorial Helpful?