WP_Query older new links navigation?
-
16-10-2019 - |
Pergunta
I'm doing a custom query using WP_query to get posts from a specific category, but for some reason navigation links for the list don't appear. Is there a way to get the newer/older links to show up and work using a custom WP_query?
This is what I'm doing:
<?php $mainList_query = new WP_Query('cat=4,352,731,754,49,44,54,17&showposts=200&order=DESC'); ?>
<?php if($mainList_query->have_posts()) : while($mainList_query->have_posts()) : $mainList_query->the_post(); ?>
<div class="articleSection">
<h2 class="headlinelist"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="byline2"><?php the_time('F jS, Y') ?> by <?php the_author() ?> at <?php the_time() ?> </div>
<?php if ( in_category( array(754,49,44,54,17) ) ) { ?>
<img src="<?php bloginfo('template_url'); ?>/images/360btn.jpg" width="67" height="16" alt="" />
<?php } ?>
<?php if ( in_category(4) ) { ?>
<img src="<?php bloginfo('template_url'); ?>/images/ps3btn.jpg" />
<?php } ?>
<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?></p>
</div>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
</div>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php get_search_form(); ?>
<?php endif; ?>
Solução
try adding '&paged='.$paged to your query string
<?php $mainList_query = new WP_Query('cat=4,352,731,754,49,44,54,17&showposts=200&order=DESC&paged='.$paged); ?>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a wordpress.stackexchange