Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can i get the posts using get_posts from let's say post 10 and beyond?So if i have 200 posts i will get from post 10 to post 200(190 posts)?

Because as i see if i use

<?php $args = array(
    'numberposts'     => -1,
    'offset'          => 10
    ); ?>

i just get all the posts

Cheers

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

It's strange, you'd have thought if you disable paging and grab all posts, that you could naturally set an offset to, eg.

array( 'nopaging' => true, 'offset' => 10 ) 

or

array( 'posts_per_page' => -1, 'offset' => 10 ) 

or

array( 'numberposts' => -1, 'offset' => 10 ) 

This unfortunately doesn't appear to work(bug / oversight in core i'd guess), however the following works, which i'd agree is not perfect, but will work.

array( 'posts_per_page' => 100000, 'offset' => 10 ) 

Just use a really high number, and it'll work around the issue of the offset not being respected when paging is disabled.

share|improve this answer
add comment
$myposts = get_posts( $args );
foreach( $myposts as $key => $post ) : setup_postdata($post); ?>

    if( $key > 10 )

    // let do it

<?php endforeach; ?>

I've never tried it berfore, I hope this helps.

share|improve this answer
    
It's not what i'm asking for because i don't want this extra looping but +1 for the try –  Argiropoulos Stavros Mar 29 '11 at 9:56
    
sry buddy if i made a mistake –  Anton Mar 30 '11 at 9:43
    
it's ok.Don't mentioned it –  Argiropoulos Stavros Mar 30 '11 at 12:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.