如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款
get_posts( array $args = null )
Retrieves an array of the latest posts, or posts matching the given criteria.
描述
The defaults are as follows:
See also #See also
Top ↑
参数
- $args
(array)
(Optional)
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. Default 0. - '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'
(bool) Whether to suppress filters. Default true.
Default value: null
返回
(WP_Post[]|int[]) Array of post objects or post IDs.