Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (is_single() && in_category('stories')) {
- $post_id = $post->ID;
- $cat = get_the_category(); //I've tried changing this to my category (both ID and slug)
- $current_cat_id = $cat[0]->cat_ID; //Also tried plugging ID and slug
- $args = array(
- 'category' => $current_cat_id, //Also tried plugging ID and slug
- 'orderby' => 'post_date',
- 'order' => 'DESC'
- );
- $posts = get_posts($args);
- $ids = array();
- foreach ($posts as $thepost) {
- $ids[] = $thepost->ID;
- }
- $thisindex = array_search($post_id, $ids);
- $previd = $ids[$thisindex - 1];
- $nextid = $ids[$thisindex + 1];
- if (!empty($nextid)) {
- ?><div class="double-grid"><a rel="next" href="<?php echo get_permalink($nextid) ?>"><div class="image-tile tile-on-archive-page" style="background-image: url('<?php echo get_the_post_thumbnail_url($nextid); ?>'"> <div class="gold-button">LAST STORY >></div></div></a></div><?php
- }
- if (!empty($previd)) {
- ?><div class="double-grid"><a rel="prev" href="<?php echo get_permalink($previd) ?>"><div class="image-tile tile-on-archive-page" style="background-image: url('<?php echo get_the_post_thumbnail_url($previd); ?>'"> <div class="gold-button">NEXT STORY >></div></div></a></div><?php
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement