Forums

next_posts_link 404 error (4 posts)

  1. solidhex
    Member
    Posted 2 years ago #

    Hi All

    I'm working on a blog that has a featured post on the home page, followed by a grid of other non-featured posts below it.

    The structure is more or less as follows :

    <?php
    // necessary for the tags to show up in a custom loop
    global $wp_query;
    $wp_query->in_the_loop = true; 
    
    // custom loop
    $q_featured = new WP_Query('&category_name=featured&showposts=1');
    while ($q_featured->have_posts()) : $q_featured->the_post();
    $do_not_duplicate = $post->ID;
    ?>

    // featured posts
    <?php endwhile; ?>

    <?php
    query_posts($query_string . '&cat=-9');
    if (have_posts()): while(have_posts()) : the_post();
    if( $post->ID == $do_not_duplicate ) continue;
    ?>

    // non featured posts

    <?php endwhile; endif; ?>

    It's 99.9% there, except that the next_posts_link function adds an extra page - it shows a third page when there are only two, which causes a 404 error. The first two pages work fine.

    Anyone else had a similar problem?

  2. Xtremefaith
    Member
    Posted 2 years ago #

    I've got the same issue right now, I'm calling it like this:

    <p class="pagination">
        <?php next_posts_link('&laquo; Previous Entries') ?>
        <?php previous_posts_link('Next Entries &raquo;') ?>
    </p>

    But nothing appears to show up, I just get this "Sorry, the page your requested could not be found, or no longer exists."

    Any help in this area would be great!

  3. batten1000
    Member
    Posted 2 years ago #

    I have this problem as well.

  4. Shane G
    Member
    Posted 2 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic