WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Broken pagination, need help figuring out why! (1 post)

  1. cmegown
    Member
    Posted 2 years ago #

    I just tried slapping together a poor-man's "featured post" section with this exact code out of my index.php:

    <div id="post-wrapper">
    <?php if (is_home() && !is_paged()) : ?>
    
        <?php query_posts('cat=13&showposts=1'); ?>
        <?php while (have_posts()) : the_post(); ?>
    
            <div class="sticky" id="post-<?php the_ID(); ?>">
    
                <h2><a class="post-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    
                <?php include('meta.php'); ?>
    
                <div class="entry">
    
                    <?php the_excerpt(); ?>
    
                    <div class="after-excerpt">
                        <?php if (has_tag()) { ?>
                            <div class="tags">
                                <img src="<?php bloginfo('template_url'); ?>/images/tag.jpg" alt="Tagged as:" />
                                <?php the_tags('', ', ', '<br />'); ?>
                            </div>
                        <?php } ?>
    
                        <div class="read-more-link">
                            <a href="<?php the_permalink(); ?>">Read More ยป</a>
                        </div>
                        <br style="clear: both" />
                    </div>
    
                </div>
    
            </div>
        <?php endwhile; ?>
    
    <?php endif; wp_reset_query(); ?>
    
    <?php query_posts('cat=-13'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <!-- do my thing for normal posts -->

    So as you can see, I've tried using multiple loops (first time trying that too :P) and the result is great...on the front page of the blog! If I were to go to the 2nd page however, it displays only the non-Feature posts that were on the first page. So in essence, it's almost working but I need your help resolving this issue!

    Also, if anyone reads this and has a better way of doing it I am all ears! This was simply my first attempt at making this feature without the use of a plugin :)

    Thanks in advance, and any/all help is much appreciated!

    EDIT:
    Issue resolved, wasn't correctly querying all other posts in 2nd loop.

    Replaced:

    <?php query_posts('cat=-13'); ?>

    with:

    <?php query_posts($query_string . '&cat=-13'); ?>

    And that simple little fix did it for me :) I hope someone else stumbles onto this topic and gets the help they need from it!

Topic Closed

This topic has been closed to new replies.

About this Topic