Well, I think the question might be a bit confusing. But well, I want to get the recent 4 posts, ignoring the first five recent posts. So in short the sixth, seventh, eighth and ninth – most recent posts.
Leave a Reply
You must be logged in to post a comment.
Simple.
WordPress provides a function called
get_posts()
that lets you get posts in any order. Basically,get_posts()
will retrieve the 5 most recent posts by default.To get 4 posts, ignoring the 5 most recent, you’d set the
numberposts
andoffset
parameters –offset
tells the function how many posts to skip.Now you have an array of posts the 4 latest posts (ignoring the 5 most recent), ordered by date.
You can use the offset parameter – either on
pre_get_posts
hook (see this post) for the ‘main Loop’:Or for subsequent secondary loops:
(Of course other argument can be included in the argument array)