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
and offset
parameters – offset
tells the function how many posts to skip.
$args = array(
'numberposts' => 4,
'offset' => 5,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish'
);
$posts = get_posts( $args );
Now you have an array of posts the 4 latest posts (ignoring the 5 most recent), ordered by date.
Related Posts:
- How to return results of a get_posts() in explicitly defined order
- Is it better practice to use query_posts, WP_Query, or get_posts to create various custom loops within a Page?
- how could I get the pagination as I want to when query posts using get_posts function
- Post count per (day/month/year) since blog began
- making random query button using $_GET
- how to exclude “featured” posts from the main loop?
- Show Only Posts Owned By Logged In User + my post
- WordPress pagination with get_posts?
- My post repeats itself on the second page [closed]
- get_the_title outputs title until spacing; it does not get full length of title
- WordPress query reverse order
- Multiple posts/pages in one page?
- Posts being viewed
- Querying a query
- allow user to edit posts made by others users based on the user role
- Post per page not working
- query_posts works while get_posts doesn’t
- When should you use WP_Query vs query_posts() vs get_posts()?
- Using WP_Query to Query Multiple Categories with Limited Posts Per Category?
- How to show related posts by category
- Is there a way to exclude the content from the post variable to save on RAM usage?
- Display/query post formats
- How to query post by user role?
- query_posts() in function makes global $wp_query out of sync?
- Limiting query_posts to 1, regardless of sticky post?
- WordPress Custom Query
- How should I intercept the main query and inject custom join / order by / group by criteria
- advice on creating a ‘related posts’ query like the one used on stackexchange
- Help altering a query to exclude all but standard post format
- List users with the most total posts view
- How to limit search to first letter of title?
- Getting movie and serial on actor page
- Post Title displaying but not in the wrapped HTML I need
- WordPress get posts by date without query_posts
- How to find out what “Blog pages show at most” is set to [duplicate]
- How to ensure that is_search() return false after query_posts
- Inserting Post Using wp_insert_post. How to Fill Yoast Plugin SEO Fields
- Why is that gdsr_sort=thumbs (GD start rating plugin) only works with query_posts and not with WP_Query?
- Query_posts $query_string
- Quickest way to get last or oldest post date – WP Query
- How to order posts by slug using query_posts/ Wp_query
- Order by meta_key with two meta_queries
- Search stores (custom postcode field) within 5, 10, 15 miles of user inputted postcode.. Code modification
- What is the difference between “manage_{$post_type}_posts_columns” and “manage_edit-{$post_type}_columns”?
- How to show only today’s post?
- use query_posts to return a post OR a page by ID
- How do you Query posts with nothing in common?
- ACF Custom Field WP_Query, but need to get all posts, if field doesn’t exist
- Combine query_posts() and get_posts() into single query
- How do I make archives.php for one category only?
- query_posts for child pages
- orderby:date not working
- WordPress pagination showing same posts on each page
- Placing post data (title, date, and excerpt) nested in static content
- Single meta key with multiple meta value in like comparison
- Inserting custom data to the_post() during loop
- Authors List page – How to include only those with wp_user_level as Author
- list child page items (1 level with meta keys)
- Get link which associated with a specific category and tag
- Sorting a query Field by date
- Show Blogroll of another WordPress site
- Trying to package posts for republishing by partner offsite
- Why this code causes infinite loop?
- Each post is showing twice in my custom query…?
- How to get posts from a current post’s month?
- number of posts per page + random + exclude categories
- While loop articles – if statement order
- query_posts() – problem with “s” parameter
- How to Query Post
- query_post and wpdb returning different results
- Exclude current sticky post
- Page title in post query
- query_posts pagination will always show identical content
- Question about querying posts
- How to list most popular post
- WordPress Custom Query to get Most Commented Posts in the Past 7 Days
- How can I query for all children posts regardless of parent
- INSERT in table row fatal error
- complex get_posts() query to select child pages
- Post Filtering by GET URL parameters
- Posts query according to meta box date
- WP-API: get posts in multiple categories
- Restrict query_posts by Date?
- How to solve this without flushing the rewrite rules for each post query the visitor triggers?
- How to query for a page, get data, then query for child pages of that page
- Get posts from current category?
- Sort post by custom field numeric value
- Notting but the latest post content keeps on being loaded
- query_posts doesnt show pages with given ID when post_type => page
- Having an issue doing a WP_Query with post_content and category__and
- How to put posts in pages using query posts
- Query add html after set amount of posts?
- Custom loop off by one post
- How to setup blog page to render blog posts minus afew categories
- How to get max value of filtered query post
- Ordering of posts, 2020 Year showing as next event when should be last
- How to display most popular post by views count in WordPress?
- How to optimize ‘select found_rows()’ query? Several ‘high load average’ alerts daily
- query multiple posts by id using a string parameter, not array()
- Query posts in a category and include only one post per author?