ThemeShaper Forums » Thematic

[closed]

Custom Loop page navigation not working

(3 posts)
  • Started 2 years ago by Gramsen
  • Latest reply from Gramsen
  • This topic is resolved
  1. Gramsen
    Member

    Greetings fellow themeshapers!

    I've been sitting here for a day or two now, banging my head against the wall trying to figure out what on earth i'm doing wrong.
    I've been trying to build a custom loop for the blog-page. Looking like this:


    function cs_indexloop() {
    query_posts("posts_per_page=4");
    $counter = 1;
    if (have_posts()) : while (have_posts()) : the_post(); ?>

    <div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
    <?php echo thematic_postheader_posttitle();
    // thematic_postheader();
    if ($counter == 1 && has_post_thumbnail()) {
    the_post_thumbnail('blog-thumbnail');
    } ?>
    <div class="entry-content">
    <?php the_excerpt(); ?>
    " class="more"><?php echo more_text() ?>
    <?php $counter++; ?>
    </div>
    <div class="entry-b-meta">
    "><?php comments_number('<div class="tal">0</div> Kommentarer', '<div class="tal">1</div> Kommentar', '<div class="tal">%</div> Kommentarer'); ?>
    <span class="meta-sep">|</span>
    <?php the_category(', ') ?>
    <span class="meta-sep">|</span>
    " title=""><?php echo get_the_date(); ?>
    </div>
    </div><!-- .post -->
    <?php endwhile; else: ?>
    <h2>Eek</h2>
    <p>There are no posts to show!</p>
    <?php endif;
    wp_reset_query();
    }

    The loop works fine, and it displays all the relevant data as wanted.
    Yet i can't seem to get the page-navigation to navigate through older posts, or any posts at all.

    I've been trying the thematic_navigation_below(); , and the posts_navigation to no avail. On both of the options the page reloads, and the url changes; but the posts displayed are the same as before, even though there's way more posts than them.

    I can't seem to wrap my head around what i'm missing, or if i've done something wrong in the new custom loop. =/

    Any help or direction would be very much appreciated.
    Thanks for reading.

    - Thomas

    Posted 2 years ago #
  2. middlesister
    Member

    This is because your query has overridden the paged variable (and all the rest of the query too). Change it to

    global $query_string;
    query_posts( $query_string . '&posts_per_page=4' );

    or

    global $wp_query;
    $my_args = array (
    	'posts_per_page' => '4'
    );
    $args = array_merge( $wp_query->query, $my_args );
    query_posts( $args );
    Posted 2 years ago #
  3. Gramsen
    Member

    Hello middlesister,

    Thanks for the swift reply, worked like a charm!
    Have a nice day :)

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.