• I made a loop for my archive.php pages. The loop need to show the last x posts and add a pagination.

    My current loop is like this:

    <?php
    $style_classes = array('span5 odd', 'span7 even');
    $styles_count = count($style_classes);
    $style_index = 0;
    while ( have_posts() ) : the_post(); ?>
    
    <article id="post-<?php the_ID();?>" class="<?php $k = $style_index % $styles_count; echo "$style_classes[$k]"; $style_index++; ?>">
    
    ..Here comes the content of the post..
    
    </article>
    <?php endwhile; ?>
    
    <?php numeric_pagination(); ?>

    I have a counter for odd and even in the loop to echo the posts on the right way in the framework. The problem is that I cant add a pagination code in the loop.

    At the moment when I use this code in my loop:

    $wp_query->query('posts_per_page=10'.'&paged='.$paged);

    It will forget that it have to show the archive of a category and shows all posts.

    This works for a specific blog page or homepage were every post is shown from new to old but it breaks on my archive pages. What am I doing wrong here?

    [No bumping, thank you.]

  • The topic ‘What is wrong with my loop for archive pages?’ is closed to new replies.