Skip to content

Instantly share code, notes, and snippets.

@marisqaporter
Forked from cjkoepke/functions.php
Last active August 29, 2015 14:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marisqaporter/d4465cf298e15b61b63c to your computer and use it in GitHub Desktop.
Save marisqaporter/d4465cf298e15b61b63c to your computer and use it in GitHub Desktop.
/**
*
* @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 ); ?>">&larr; 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; ?> &rarr;</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 );
/* 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