get_posts() WP 1.0
Retrieve list of latest posts or posts matching criteria.
The defaults are as follows:
Works based on: WP_Query()
1 time = 0.0036s = very slow | 50000 times = 99.1s = very slow
No Hooks.
Return
WP_Post[]/Int[]. Array of post objects or post IDs.
Usage
get_posts( $args );
- $args(array)
Arguments to retrieve posts. See WP_Query::parse_query() for all available arguments.
-
numberposts(int)
Total number of posts to retrieve. Is an alias of $posts_per_page in WP_Query. Accepts -1 for all.
Default: 5 -
category(int/string)
Category ID or comma-separated list of IDs (this or any children). Is an alias of $cat in WP_Query. -
include(array)
An array of post IDs to retrieve, sticky posts will be included. Is an alias of $post__in in WP_Query.
Default: empty array -
exclude(array)
An array of post IDs not to retrieve.
Default: empty array - suppress_filters(true/false)
Whether to suppress filters.
Default: true
Default: null
-
Notes
- See: WP_Query::parse_query()
Changelog
Since 1.2.0 | Introduced. |
Code of get_posts() get posts WP 5.6
Related Functions
From tag: query
More from category: Queries
- get_post()
- in_the_loop()
- is_404()
- is_archive()
- is_attachment()
- is_author()
- is_category()
- is_date()
- is_day()
- is_feed()