get_posts()
has some defaults set, including numberposts
equal to 5
. Since it’s not considered to be a loop by itself those are independent and not affected by admin settings.
So simply pass in arguments numberposts
/posts_per_page
(same thing) number for how many posts you want or -1
for all matching posts.
Related Posts:
- When should you use WP_Query vs query_posts() vs get_posts()?
- When to use WP_query(), query_posts() and pre_get_posts
- How to use the_posts_navigation for wp_query and get_posts?
- meta_query: using BETWEEN with floats and/or casting to DECIMAL
- How to order by post_status?
- Using get_posts vs. WP_Query
- Delete all posts from WordPress except latest X posts
- Differences Between WP_Query() and get_posts() for Querying Posts?
- Get Recent Posts by Date in Multisite
- get_posts with multiple categories
- get_template_part in for loop
- Use of caller_ get_ posts
- Is it possible to select against a post’s parent’s fields with WP_Query?
- Query all posts where meta value is empty
- Get posts by meta data OR title
- Get_post() with meta_key when compare is a date
- get_posts not finding argument: post_name
- Meta Query with date and time on the same Day before given time
- Function to check if author has posted within the last x days
- Use post__in and post__not_in together?
- Different Results with query(‘s=computer’) vs get_posts(‘s=computer’)?
- WP Query post meta value
- Get all posts without tags
- get_posts() seemingly ignoring post_type
- Can not switch the queried post in pre_get_posts hook
- How to find out what “Blog pages show at most” is set to [duplicate]
- Count posts returned by get_posts in external PHP script
- Trying to check and see if a post has a featured image outside of the main loop
- WP_query category__in not working, only pulls from first category
- SELECT * FROM $wpdb->posts WHERE ID > 160
- Adding multiple post queries with parent and children to page – Best Way
- How do you Query posts with nothing in common?
- WP_Query, tax_query and term_meta: How to?
- Get posts for last working week in WP_Query
- Create a sitemap without a plugin – get parent pages only?
- Creating a custom search for a specific post type
- get_posts – find out if querystring was crap and fallback is used
- Get posts for which a custom field is not present, with get_posts
- Creating query to show which editor (classic or block) was last used to edit a post/page
- Return Taxonomy/Term Information with Posts (WP_Query/get_posts)
- Help with WP_Query – Too many mySQL queries
- WP_Query() and get_posts() can’t handle over a thousand posts?
- add active class based on permalink and url
- Weird orderby => post__in issue
- Why does get_posts only show results for Admins or logged-out users?
- Conflict with get_posts and the_content
- get_post_meta slowing down my page load (in a plugin)
- How to show more post at a given category?
- Get posts by list of post IDs ordered by those IDs?
- Check return value of get_posts
- Reset WordPress Post Query to default
- Best choice for multiple loop in page?
- Get all posts which was posted on X Days WordPress
- Query post with meta value in set of values
- meta_query: check if number exists
- Use WP_Query or query_posts() or get_posts() for optimizing a site?
- “paged” in WP_Query returns 0 posts
- Specify strict ‘order by’ in WordPress query
- complex get_posts() query to select child pages
- How I can change the condition or compare operator for WP_Query in pre_get_posts
- Check if searched number is within the post meta value
- get_posts custom field
- How to apply a function to a metadata value before launch a WP Query?
- Posts query according to meta box date
- Woocommerce: order posts by meta key
- WP_User_Query and user posts
- How to access $wp_query object from array of posts given by get_posts?
- Function using get_posts() with tax_query not working when called from functions.php
- get_posts query matches too many results
- Search for pages with permalink
- How to query for a page, get data, then query for child pages of that page
- Why always one post missing
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- How to add date_query to meta_query array
- Why my query is not “Main_query”?
- Facing problem with tax_query results
- get_posts query is taking about 40 seconds to execute
- Related posts queries
- how to get wp_query posts only first letter of alphabet A?
- get_posts query caching?
- Get posts with any value in attribute
- Slow query when selecting with large meta query or post__in
- I cannot get tax_query in get_posts() to work with custom taxonomy
- Getting the last X posts, but in ascending order of time
- how to avoid reloading/refresh the page when displaying the post of wp_list_categories
- Display posts from catagories
- Both WP_Query and get_posts returning 1 post
- When should you use WP_Query vs query_posts() vs get_posts()?
- Why WP_Query in functions.php is not working when get_posts works?
- Retrieve posts in custom post type and specific taxonomies
- Weird query with get_posts and WP_Query
- orderby and order filter in get_posts or WP_query function in wordpress not working
- tax_query not working properly with get_posts
- Query custom post types by meta field in a term from custom taxonomy
- How to replecate the _fields parameter in custom REST api endpoint
- How to retrieve _embed (etc) fields in get_posts custom query?
- Empty query on Custom Post Type, using WP_Query or get_posts
- A Depth Like Parameter For “get_posts”
- Sort by multiple columns using get_posts
- How to cache wordpress get_posts query using transients?