Site icon Hip-Hop Website Design and Development

get_next_posts_link() stops displaying at page 4

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..

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');