continues(loop) page navigation with get_permalink()
-
Hello,
I already searched the forum with this problem and I found a lot of good information but I’m still not possible to solve my problem. I’m sorry about that.I would like to turn my page navigation in to a loop. I’m quit close but my problem is that I’m not able to switch between the categories. At the moment I have a loop inside of the categorie but I’m not able to jump to the next categorie.
My script:
<?php $prev_post = get_adjacent_post( true, '', true ); $next_post = get_adjacent_post( true, '', false ); $prev_post_id = $prev_post->ID; $next_post_id = $next_post->ID; ?>
<?php if(($prev_post_id === '') || ($prev_post_id === null)) : $query = new WP_Query(array('order' => 'DESC', 'posts_per_page' => '1', 'cat=4')); if($query->have_posts()) : while($query->have_posts()) : $query->the_post(); $prev_post_id = get_the_ID(); endwhile; endif; wp_reset_postdata(); endif; if(($next_post_id === '') || ($next_post_id === null) ) : $query = new WP_Query(array('order' => 'ASC', 'posts_per_page' => '1', 'cat=4')); if($query->have_posts()) : while($query->have_posts()) : $query->the_post(); $next_post_id = get_the_ID(); endwhile; endif; wp_reset_postdata(); endif; ?>
<div id="left"> <a href="<?php echo get_permalink($prev_post_id); ?>" class="myCursorPrev"> </a> </div> <div id="right"> <a href="<?php echo get_permalink($next_post_id); ?>" class="myCursorNext"> </a> </div>
$query = new WP_Query(array('order' => 'ASC', 'posts_per_page' => '1', 'cat=4'));
I tried different usage with the cat=4 or cat=1,2,3,4 but it has no effect.thanks for any help.
best, carol
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘continues(loop) page navigation with get_permalink()’ is closed to new replies.