Title: Problem with get_posts()
Last modified: August 19, 2016

---

# Problem with get_posts()

 *  [Fatih Turan](https://wordpress.org/support/users/fatihturan/)
 * (@fatihturan)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/problem-with-get_posts/)
 * I’m using `get_posts()` function for display my most like this code snippet:
 *     ```
       <ul id="archive_posts">
       <?php $i = 0; ?>
       <?php $myposts = get_posts('numberposts=-1&cat=-5');
       foreach($myposts as $post) : ?>
       <?php $i++; ?>
       <li><a href="<?php the_permalink(); ?>" <?php if($i&1) { echo 'class="odd"';} else {echo 'class="even"';} ?>><?php the_title(); ?><span><?php the_time('d F Y H:i') ?></span></a></li>
       <?php endforeach; ?>
       </ul>
       ```
   
 * And i want to use next/previous links. But WordPress doesn’t allow to display
   prev/next links without loop.
 * However i want to use next/prev links with above codes.
 * Can anybody help me?

Viewing 1 replies (of 1 total)

 *  [stvwlf](https://wordpress.org/support/users/stvwlf/)
 * (@stvwlf)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/problem-with-get_posts/#post-1237344)
 * try using a wp_query loop
    [http://weblogtoolscollection.com/archives/2008/04/13/define-your-own-wordpress-loop-using-wp_query/](http://weblogtoolscollection.com/archives/2008/04/13/define-your-own-wordpress-loop-using-wp_query/)
   See the part about pagination at the end
 * and also this follow on article
    [http://weblogtoolscollection.com/archives/2008/04/19/paging-and-custom-wordpress-loops/](http://weblogtoolscollection.com/archives/2008/04/19/paging-and-custom-wordpress-loops/)

Viewing 1 replies (of 1 total)

The topic ‘Problem with get_posts()’ is closed to new replies.

## Tags

 * [get_posts](https://wordpress.org/support/topic-tag/get_posts/)
 * [pagination](https://wordpress.org/support/topic-tag/pagination/)

 * 1 reply
 * 2 participants
 * Last reply from: [stvwlf](https://wordpress.org/support/users/stvwlf/)
 * Last activity: [16 years, 8 months ago](https://wordpress.org/support/topic/problem-with-get_posts/#post-1237344)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
