Title: Problems with old posts with this code
Last modified: August 20, 2016

---

# Problems with old posts with this code

 *  [mankulito](https://wordpress.org/support/users/mankulito/)
 * (@mankulito)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/problems-with-old-posts-with-this-code/)
 * I am using this code, to have posts in columns. With this code i can’t see pages
   with older posts. i can open page/2 but there is only the same posts i have in
   first page. do u know how to fix it, guys? 🙁
 *     ```
       <?php query_posts('showposts=5'); ?>
        <?php $posts = get_posts('numberposts=5&offset=0'); foreach ($posts as $post) : start_wp(); ?>
        <?php static $count1 = 0; if ($count1 == "5") { break; } else { ?>
       <?php the_title(); ?>
        <?php the_content(); ?>
       <?php $count1++; } ?>
        <?php endforeach; ?>
       ```
   
 * _[Please post code or markup snippets between backticks or use the code button.]_

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

 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/problems-with-old-posts-with-this-code/#post-2515746)
 * [http://vudu.me/10f](http://vudu.me/10f)
 * Check that out, you just need to account for pagination in your query.
 * query_posts kills the original query, so pagination gets stomped. You can just
   put it back in!
 *  Thread Starter [mankulito](https://wordpress.org/support/users/mankulito/)
 * (@mankulito)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/problems-with-old-posts-with-this-code/#post-2515756)
 * When i add this in the end, it is still not working:
 *     ```
       <?php query_posts( array(
             'posts_per_page' => 3,
             'cat' => '',
             'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),
        ));
       ?>
       ```
   
 * _[Please post code or markup snippets between backticks or use the code button.]_
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/problems-with-old-posts-with-this-code/#post-2515776)
 * I’m trying to figure out what you are doing exactly?
 * In your top bit of code…. you use query_posts, and get_posts
 * You wouldn’t need both.
 * Also, you wouldn’t add all that code you just pasted at the end. You need to 
   incorporate the paged parameter into your query.
 *  Thread Starter [mankulito](https://wordpress.org/support/users/mankulito/)
 * (@mankulito)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/problems-with-old-posts-with-this-code/#post-2515797)
 * i have 3 columns. In first i have this:
 *  <?php query_posts(‘showposts=3’); ?>
    <?php $posts = get_posts(‘numberposts=
   5&offset=0’); foreach ($posts as $post) : start_wp(); ?> <?php static $count1
   = 0; if ($count1 == “3”) { break; } else { ?>
 * <div id=”post-<?php the_ID(); ?>” class=”post”>
    <div class=”postMeta”> <p class
   =”container”> <span class=”date”><?php the_time(‘M j, Y’) ?></span> <span class
   =”comments”><?php comments_popup_link(‘0’, ‘1’, ‘%’); ?></span> </p> </div> <
   h2>” title=”<?php the_title(); ?>”><?php the_title(); ?></h2> <div class=”entry”
   > <?php the_content(); ?> </div>
 * <?php $count1++; } ?>
    <?php endforeach; ?>
 * second:
    ————————
 *  <?php query_posts(‘showposts=3’); ?>
    <?php $posts = get_posts(‘numberposts=
   5&offset=3’); foreach ($posts as $post) : start_wp(); ?> <?php static $count2
   = 0; if ($count2 == “3”) { break; } else { ?>
 * <div id=”post-<?php the_ID(); ?>” class=”post”>
    <div class=”postMeta”> <p class
   =”container”> <span class=”date”><?php the_time(‘M j, Y’) ?></span> <span class
   =”comments”><?php comments_popup_link(‘0’, ‘1’, ‘%’); ?></span> </p> </div> <
   h2>” title=”<?php the_title(); ?>”><?php the_title(); ?></h2> <?php the_content();?
   > </div>
 * <?php $count2++; } ?>
    <?php endforeach; ?>
 * and third:
    ——————-
 *  <?php query_posts(‘showposts=3’); ?>
    <?php $posts = get_posts(‘numberposts=
   5&offset=6’); foreach ($posts as $post) : start_wp(); ?> <?php static $count3
   = 0; if ($count3 == “3”) { break; } else { ?>
 * <div id=”post-<?php the_ID(); ?>” class=”post”>
    <div class=”postMeta”> <p class
   =”container”> <span class=”date”><?php the_time(‘M j, Y’) ?></span> <span class
   =”comments”><?php comments_popup_link(‘0’, ‘1’, ‘%’); ?></span> </p> </div> <
   h2>” title=”<?php the_title(); ?>”><?php the_title(); ?></h2> <div class=”entry”
   > <?php the_content(); ?> </div>
 * <?php $count3++; } ?>
    <?php endforeach; ?>
 * so, i have 3 columns with 3 posts in each column. Can u please tell what and 
   how i need to change to make older posts work?
    ———-
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/problems-with-old-posts-with-this-code/#post-2515840)
 * hm. THis is so not my area of strength… first up though in your query, showposts
   is deprecated a long time ago. posts_per_page is current
 * [http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters)
 * As for the query, maybe turning
 *     ```
       <?php query_posts('showposts=3'); ?>
       ```
   
 * into
 *     ```
       <?php query_posts( array(
             'posts_per_page' => 3,
             'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),
        ));
       ?>
       ```
   
 * would do it? (YOu said you put it at the end, that isn’t rightm you need to add
   it to your existing query which is what I did here)
 * I’m not sure if that needs to happen on all your loops or what… like I said, 
   not my area. Hopefully this can help you a little…. if not, I’ll have to hope
   someone else can jump in
 *  Thread Starter [mankulito](https://wordpress.org/support/users/mankulito/)
 * (@mankulito)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/problems-with-old-posts-with-this-code/#post-2515868)
 * still not working. Thanks anyway, i ll try to find different way to split post
   in columns.

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

The topic ‘Problems with old posts with this code’ is closed to new replies.

## Tags

 * [older entries](https://wordpress.org/support/topic-tag/older-entries/)
 * [pages](https://wordpress.org/support/topic-tag/pages/)
 * [previous posts link](https://wordpress.org/support/topic-tag/previous-posts-link/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 6 replies
 * 2 participants
 * Last reply from: [mankulito](https://wordpress.org/support/users/mankulito/)
 * Last activity: [14 years, 4 months ago](https://wordpress.org/support/topic/problems-with-old-posts-with-this-code/#post-2515868)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
