• Please help and pardon me if the answer is posted somewhere else, perhaps someone could direct me to it.

    I am using my blog as a blog and cms of sorts. Really the issue is that on my index I am excluding several categories that I do not want to show up within the wordpress loop (they are not “blog” items). The exclusion works within the loop, but then are the foot of the page I include the “posts_nav_link()” function to display new/older posts/post pages. The posts_nav_link function is displaying links to empty pages, and i am assuming it is because it is reading that i have the posts, bt then is being told not to display them.

    So say I have 32 total posts, but only 1 in a category that i am trying to display within the wp loop. posts_nav_link generate 3 empty pages (where the first page displays my 1 post and the follwing 3 are empty pages).

    Does anyone know how i can fix this? btw i have also tried using te plugin PageNavi, but that still does the same thing… any fixes?
    Many thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you aren’t excluding the posts with the acutal query itself, then you will likely have paging problems.

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('cat=-1&paged=' . $paged);
    ?>

    See the template tag, query_posts(), for other parameters.

    Thread Starter generalfancy

    (@generalfancy)

    Thank you for looking in this. Still having a bit of trouble, but things are better. I had a bit of trouble with your snipet. Perhaps you could explain it a bit better in regards to its placement (i am a rookie at this). I used this instead:

    <?php if (have_posts()) :
    $my_query = new WP_Query('cat=-3,-4,-5,-6,-7'.'&paged='.$paged);
    	while ( $my_query->have_posts() ) : $my_query->the_post();
    ?>

    Now in a category i want to display I only have 1 post, while I have several posts below the main loop in a separate query and another in the sidebar.
    I am using the PageNavi plugin…With the the query I used above, the plugin displays 4 pages at the bottom… I page to the second page, it is empty, and PageNavi displays nothing (better than before though, it was allowing me to page through all 4 pages).

    This is how i am getting the other “side post” areas:

    <?php $postslist = get_posts('category=4,5,6,7&numberposts=2&order=DESC&orderby=post_date');
    
    foreach ($postslist as $post) :
    setup_postdata($post); ?>

    I am doing the side post areas incorrectly?
    Thanks Again!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘posts_nav_link trouble, excluded posts generate empty pages’ is closed to new replies.