arrays - Wordpress: Continues(loop) page navigation with get_permalink() -
i turn page navigation in loop. i'm quit close problem i'm not able switch between categories. @ moment have loop inside of category i'm not able jump next category.
as information: have different post categories.
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 cat=4 or cat=1,2,3,4 has no effect.
Comments
Post a Comment