1
I am trying to activate Wordpress pagination in a theme’s Category.php file, but the pagination links do not appear. From the little I researched, it would have something to do with the use of custom queries, but I didn’t quite understand its use.
How I could activate paging (either native or with the WP Postnavi plugin) in my page code, shown below?
<?php get_header(); ?>
<main>
<div id="content_internas">
<div id="lista_noticias">
<h2><span><?php echo strtoupper(single_cat_title( '', false )) ?></span></h2>
<ul>
<?php $posts = get_all_posts(null, get_cat_id( single_cat_title("",false) )); ?>
<?php foreach($posts as $key => $post): ?>
<li>
<a href="<?php the_permalink() ?>">
<?php if (function_exists('has_post_thumbnail')) {
if (has_post_thumbnail()) { ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(array(460, 300, true)); ?></a>
<?php } } ?>
</a>
<br />
<span><?php the_time('j F') ?></span>
<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
<p><?php the_excerpt(); ?></p>
</li>
<?php endforeach; ?>
</ul>
<div class="paginacao">
<?php if(function_exists('wp_pagenavi')) : ?>
COM PLUGIN
<?php wp_pagenavi() ?>
<?php else : ?>
SEM PLUGIN
<div class="maisantigos"><?php next_posts_link(__('« Mais antigos','arclite')) ?></div>
<div class="maisrecentes"><?php previous_posts_link(__('Mais recentes »','arclite')) ?></div>
<?php endif; ?>
</div>
<!--<center><a href="#" id="veja_mais">MAIS NOTÍCIAS</a></center>--><br> <br>
</div>
</div>
</main>
<?php get_footer(); ?>
Some information is missing: is the wp_pagenavi plugin active and configured to be displayed even when there is only one page? It simply doesn’t display or display an error message instead? In the code you posted, you see the message "WITH PLUGIN"?
– Blau
Please put your code here, if the Pastebin disappear the question loses its meaning. You can [Dit] the post and include the code.
– brasofilo
Sorry for the lack of information. Actually my intention was to make the code redundant, can be used with or without Pagenavi.
– Giancarlo Silva