Skip to content

Instantly share code, notes, and snippets.

@csknk
Last active December 27, 2015 13:59
Show Gist options
  • Select an option

  • Save csknk/7337581 to your computer and use it in GitHub Desktop.

Select an option

Save csknk/7337581 to your computer and use it in GitHub Desktop.
Infinite Next/Previous links for CPT = project, attached to a Thesis 2.1 hook
/**Infinite next & previous project links**/
function add_next_project() {
if( get_adjacent_post(false, '', true) ) {
?><div class ="half"><?php echo previous_post_link('%link', '&laquo View Previous Project');?></div><?php
}
else {
$first = new WP_Query('post_type=project&order=DESC'); $first->the_post();
echo '<a href="' . get_permalink() . '">&laquo; View Previous Project</a>';
wp_reset_postdata();
};
if( get_adjacent_post(false, '', false) ) {
?><div class="half_right"><?php echo next_post_link('%link', 'View Next Project &raquo');?></div><?php
}
else {
$last = new WP_Query('post_type=project&order=ASC'); $last->the_post();
?><div class="half_right"><?php echo '<a href="' . get_permalink() . '">View Next Project &raquo;</a>';?></div><?php
wp_reset_postdata();
};
}
add_action('hook_bottom_next_in_cat', 'add_next_project');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment