-
-
Save marisqaporter/d4465cf298e15b61b63c to your computer and use it in GitHub Desktop.
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
/** | |
* | |
* @author Calvin Makes | |
* @link http://www.calvinmakes.com/ | |
* @version 1.0 | |
* | |
* Add previous and next buttons to custom post types. | |
*/ | |
function cm_custom_navigation_links() { | |
// Check to see if the post is a custom post type, and if it is on the post view. | |
// If so, execute the function. | |
// Replace 'work' with your custom post type slug. | |
if( 'team-member' == get_post_type() && is_single() ) { | |
// Set variables for ease of use. | |
$older_post = get_previous_post(); | |
$newer_post = get_next_post(); | |
// If the $older_post returns a value, display the markup. | |
if ( ! empty($older_post) ): ?> | |
<a class="custom-pre" href="<?php echo get_permalink( $older_post->ID ); ?>">← Meet <?php echo $older_post->post_title; ?> </a> | |
<?php endif; | |
// If the $newer_post returns a value, display the markup. | |
if ( ! empty($newer_post) ): ?> | |
<a class="custom-next" href="<?php echo get_permalink( $newer_post->ID ); ?>">Meet <?php echo $newer_post->post_title; ?> →</a> | |
<?php endif; | |
} | |
} | |
// Hook the output before the content. You can use whatever hook fits your scenario, however. | |
add_action('genesis_after_content', 'cm_custom_navigation_links', 5 ); |
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
/* Custom Post Type Pagination | |
--------------------------------------------- */ | |
.custom-pre { | |
float: left; | |
margin-bottom: 10px; | |
} | |
.custom-next { | |
float: right; | |
margin-bottom: 10px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment