get_next_posts_link() stops displaying at page 4

Question

Please start by taking a look at this quick video: http://www.screenr.com/8vSH

The problem: get_next_posts_link() disappears on page 4. That is, the “go to older posts” link disappears once I am in &paged=4 of my blog. However, I can manually type eg. &paged=5 and I do get the fifth page’s posts (which means, the posts are there, but the get_next_posts_link() is just not showing up).

So..

  • Printing my total posts-number returns the correct amount (33), which tells me that all my posts are being queried properly.
  • The posts and blog-pages are working properly (i.e. I can type &paged=5 or 6 or so on), and I do get that specific blog-page with the corresponding posts.
  • I have also tried next_posts_link() to no avail.

The current code looks like this:

echo '<ul class="blog-navi">
                <li class="blog-navi-prev">'.get_next_posts_link($pagi_older_text, 0).'</li>
                <li class="blog-navi-next">'.get_previous_posts_link($pagi_newer_text).'</li>
            </ul>';

Thank you!

The posts query

get_header();

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

$blogcats = $era_opts['era_opts_blog_thecats'];
if(!isset($era_opts['era_opts_blog_thecats'])) {
    $blogcats = '';
} else {
    $blogcats = implode(',', $blogcats);
}

$args = array(
    'post_type' => 'post',
    'numberposts' => '-1',
    'paged' => $paged,
    'category' => $blogcats
);
$era_blog_posts = get_posts($args);

The added pre_get_posts function in functions.php

function era_blog_cats_wpse_103587($qry) {
  if ($qry->is_page(122) && is_main_query()) {
    $era_opts = get_option('era_theme_panel');
    $blogcats = $era_opts['era_opts_blog_thecats'];

    if(!empty($era_opts['era_opts_blog_thecats'])) {
      $qry->set('category__in', $blogcats);
    }
  }
}
add_action('pre_get_posts','era_blog_cats_wpse_103587');
0
, cr0z3r 8 months 0 Answers 71 views 0

Leave an answer