Skip to content

Instantly share code, notes, and snippets.

@grantambrose
Last active August 6, 2016 21:53
Show Gist options
  • Save grantambrose/506d6a79db7cc73c73990e5b9fda7aad to your computer and use it in GitHub Desktop.
Save grantambrose/506d6a79db7cc73c73990e5b9fda7aad to your computer and use it in GitHub Desktop.
Add previous / post links to single posts
// add previous / next posts to single posts
// change fl_post_bottom_meta_open to the hook that is appropriate to your theme. Genesis would use genesis_before_comments as the hook
add_action( 'fl_post_bottom_meta_open', 'eo_prev_next_post_nav' );
function eo_prev_next_post_nav() {
if ( is_single() ) { ?>
<div class="navi-previous-next clear clearfix">
<div class="navi-previous navi-item"> <?php
$prevPost = get_previous_post();
$prevthumbnail = get_the_post_thumbnail($prevPost->ID, 'medium'); ?>
<p class="navi-icon"><?php previous_post_link('%link', '&larr; <span class="navi-title">Previous Article</span>');?></p>
<div class="navi-post-content">
<?php previous_post_link('%link', $prevthumbnail); ?>
<?php previous_post_link('%link', '%title'); ?>
</div>
</div>
<div class="navi-next navi-item"> <?php
$nextPost = get_next_post();
$nextthumbnail = get_the_post_thumbnail($nextPost->ID, 'medium'); ?>
<p class="navi-icon"><?php next_post_link('%link', '<span class="navi-title">Next Article</span> &rarr;'); ?></p>
<div class="navi-post-content">
<?php next_post_link('%link', $nextthumbnail); ?>
<?php next_post_link('%link', '%title'); ?>
</div>
</div>
</div>
<?php }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment