Skip to content

Instantly share code, notes, and snippets.

@topleague
Last active December 3, 2019 07:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save topleague/74eef1c69a8cf968002db0e60c2e0ef6 to your computer and use it in GitHub Desktop.
Save topleague/74eef1c69a8cf968002db0e60c2e0ef6 to your computer and use it in GitHub Desktop.
Previous/Next Post in Genesis (Featured Image)
// ADD NEXT/PREV POST + Add Featured Images To Previous & Next Post Nav Links
add_action('genesis_after_entry', 'wpsites_image_nav_links', 9 );
/**
* @author Brad Dalton
* @link http://wpsites.net/web-design/add-featured-images-to-previous-next-post-nav-links/
* //https://crunchify.com/how-to-display-last-updated-on-datetime-of-your-wordpress-blog-post-genesis-framework-hook-included/
//https://stackoverflow.com/questions/7563568/display-post-date-on-previous-next-link
// https://sridharkatakam.com/add-links-previous-post-next-post-single-posts-genesis/
*/
function wpsites_image_nav_links() {
if( !is_singular('post') )
return;
if( $prev_post = get_previous_post() ):
echo'<span class="single-post-nav previous-post-link">';
$prevpost = get_the_post_thumbnail( $prev_post->ID, 'medium', array('class' => 'pagination-previous'));
// previous_post_link( '%link',"$prevpost <p>← Previous Post</p>", TRUE );
previous_post_link( '%link',"$prevpost" );
previous_post_link( '%link', '&#x000AB; Previous Post: %title' );
echo'</span>';
endif;
if( $next_post = get_next_post() ):
echo'<span class="single-post-nav next-post-link">';
$nextpost = get_the_post_thumbnail( $next_post->ID, 'medium', array('class' => 'pagination-next'));
//next_post_link( '%link',"$nextpost <p>Next Post →</p>", TRUE );
next_post_link( '%link',"$nextpost" );
next_post_link( '%link', 'Next Post: %title &#x000BB;' );
echo'</span>';
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment