Last active
August 29, 2015 14:00
-
-
Save stillingen/db3ff961c9e67dad2cff to your computer and use it in GitHub Desktop.
Featured Images To Previous & Next Post Nav Links
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('genesis_entry_footer', 'wpsites_image_nav_links', 25 ); | |
/** | |
* @author Brad Dalton | |
* @example http://wpsites.net/web-design/add-featured-images-to-previous-next-post-nav-links/ | |
* @copyright 2014 WP Sites | |
*/ | |
add_action('genesis_entry_footer', 'wpsites_image_nav_links', 25 ); | |
function wpsites_image_nav_links() { | |
if( !is_singular('post') ) | |
return; | |
if( $prev_post = get_previous_post() ): | |
echo'<div class="single-post-nav previous-post-link">'; | |
echo'<h2>Previous Post</h2>'; | |
$prevpost = get_the_post_thumbnail( $prev_post->ID, 'medium', array('class' => 'pagination-previous')); | |
previous_post_link( '%link',"$prevpost", TRUE ); | |
previous_post_link( '<div class="prev-link">%link</div>', '%title' ); | |
echo'</div>'; | |
endif; | |
if( $next_post = get_next_post() ): | |
echo'<div class="single-post-nav next-post-link">'; | |
echo'<h2>Next post</h2>'; | |
$nextpost = get_the_post_thumbnail( $next_post->ID, 'medium', array('class' => 'pagination-next')); | |
next_post_link( '%link',"$nextpost", TRUE ); | |
next_post_link( '<div class="next-link">%link</div>', '%title' ); | |
echo'</div>'; | |
endif; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment