Last active
December 27, 2015 13:59
-
-
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
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
| /**Infinite next & previous project links**/ | |
| function add_next_project() { | |
| if( get_adjacent_post(false, '', true) ) { | |
| ?><div class ="half"><?php echo previous_post_link('%link', '« View Previous Project');?></div><?php | |
| } | |
| else { | |
| $first = new WP_Query('post_type=project&order=DESC'); $first->the_post(); | |
| echo '<a href="' . get_permalink() . '">« 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 »');?></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 »</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