I want to get the posts from within specific ID's ( 10 - 15 ), just like we do in SQL

select * from employees limit 10 , 20 ;

I wanna get in this Wordpress posts.

  • This SQL query is about paging, but not finding specific range of ID's. The solution by @PieterGoosen should give you that range in an easy way. – birgire Jul 19 '15 at 12:33

You can simply just use the post__in parameter inside your query arguments or inside your pre_get_posts action


(Adjust as necessary. Code requires at least PHP 5.4+ due to short array syntax ([]))

$args = [
    'post__in' => range( 10, 15 ),
$q = get_posts( $args );
var_dump( $q );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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