Skip to content

Instantly share code, notes, and snippets.

@nerrad
Created August 27, 2012 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nerrad/3488456 to your computer and use it in GitHub Desktop.
Save nerrad/3488456 to your computer and use it in GitHub Desktop.
custom navigation for organize series (pagination by series part) this can be added to the themes functions.php file
add_action( 'the_content', 'os_custom_series_nav_filter' );
function os_custom_series_nav_filter($content) {
global $post;
if ( is_single() ) {
$series = get_the_series();
if ( !empty($series) ) {
$cur_id = $post->ID;
$posts_in_series = array();
$result = '';
$content .= '<div class="custom-series-navigation"><ul>';
foreach ( $series as $ser ) {
$series_id = $ser->term_id;
$series_posts = get_objects_in_term($series_id, 'series');
$posts_in_series = get_series_order($series_posts, '', $series_id, false);
foreach ( $posts_in_series as $series_post ) {
if ( $series_post['id'] == $cur_id ) {
$content .= '<li class="custom-series-nav-current">' . $series_post['part'] . '</li>';
} else {
$content .= '<li><a href="'.get_permalink($series_post['id']).'" title="'.get_the_title($series_post['id']).'">'.$series_post['part'].'</a></li>';
}
}
}
$content .= '</ul></div>';
}
}
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment