Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // get_posts in same custom taxonomy
- $postlist_args = array(
- 'posts_per_page' => -1,
- 'orderby' => 'menu_order title',
- 'order' => 'ASC',
- 'post_type' => 'lessons',
- 'your_custom_taxonomy' => 'curs'
- );
- $postlist = get_posts( $postlist_args );
- // get ids of posts retrieved from get_posts
- $ids = array();
- foreach ($postlist as $thepost) {
- $ids[] = $thepost->ID;
- }
- // get and echo previous and next post in the same taxonomy
- $thisindex = array_search($post->ID, $ids);
- $previd = $ids[$thisindex-1];
- $nextid = $ids[$thisindex+1];
- if ( isset($previd) ) {
- echo '<a rel="prev" href="' . get_permalink($previd). '">previous</a>';
- }
- if ( isset($nextid) ) {
- echo '<a rel="next" href="' . get_permalink($nextid). '">next</a>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement