Next returns ID to itself where it should return nothing
-
I have a thing like this:
<nav class="prev-next margin-t-20 float-left"> <?php $args = array( 'post_type' => 'work', 'orderby' => 'menu_order' ); $prev_post = wpqpapl($post->ID, $args, 'previous', 'ID'); $next_post = wpqpapl($post->ID, $args, 'next', 'ID'); ?> <div class="next-link margin-r-20 dehighlight"> <?php if ( !empty( $next_post ) ) { ?> <a id="next-link" href="<?php echo get_permalink( $next_post ); ?>">←</a> <?php } else { ?> ← <?php } ?> </div> <div class="prev-link dehighlight"> <?php if ( !empty( $prev_post ) ) { ?> <a id="prev-link" href="<?php echo get_permalink( $prev_post ); ?>">→</a> <?php } else { ?> → <?php } ?> </div> </nav>
I check if
$next_page
and$prev_page
have something in them and display an arraow (← or → ) inside a link to a next post.When it gets to the last post, the
previous
returns nothing, like it should, cause there is no previous posts. But when it gets to the first post, thenext
returns the current page.Is it just me or a bug? (probably just me)
https://www.ads-software.com/plugins/wp-query-powered-adjacent-post-link/
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Next returns ID to itself where it should return nothing’ is closed to new replies.