I really get stuck with pagination problem in wordpress for more than a week.
The problem: On the first blog page (basically when you just click on the nav menu “blog”) There IS a pagination – here is the source
http://advokat-belyakova.ru/blog/
by pagination I mean just next and prev buttons.
But when I click “previous posts” (“« РпÑедÑдÑÑим запиÑÑм”) right under the posts pagination. Pagination dissapears (http://advokat-belyakova.ru/blog/page/2/)
I’m using simple wp_query
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$temp = $wp_query;$wp_query= null;
$wp_query = new WP_Query(); $wp_query->query('showposts=20' . '&paged='. $paged . '&cat=-41');
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
I also tried without (this $paged I’ve found in stackoverflow but it doesn’t help me at all 🙁
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
Here is my code after the infromation i’ve got by wp_query loop
<?php endwhile; ?>
<div class="row">
<div class="col-md-12">
<?php if ($paged > 1) { ?>
<nav id="nav-posts">
<div class="prev"><p class="pagination"><?php next_posts_link('« РпÑедÑдÑÑим запиÑÑм'); ?></p></div>
<div class="next"><p class="pagination pagination-next"><?php previous_posts_link('РновÑм запиÑÑм »'); ?></p></div>
</nav>
<?php } else { ?>
<nav id="nav-posts">
<div class="prev"><?php next_posts_link('« РпÑедÑдÑÑим запиÑÑм'); ?></div>
</nav>
<?php } ?>
</div>
</div>
<?php wp_reset_postdata(); ?>
I’m sorry for russian language in my web site examples. I hope it will be enough and you’ll be able to understand what my problem is.
I have static main page template (custom) but i really haven’t got this problem in the past. If additional info is necessary please ask for it
Find a function that works in my situation
Here is the function:
The wp_query in blog-page.php (actually almost the same):
After getting content inside the loop:
Some basic css for displaying pagination
Dont forget to say thanks to this guy. http://www.wpexplorer.com/pagination-wordpress-theme/