2020-05-01 / 1796阅 / 悠然
Retrieve all children of the post parent ID.
Normally, without any enhancements, the children would apply to pages. In the context of the inner workings of WordPress, pages, posts, and attachments share the same table, so therefore the functionality could apply to any>get_posts() function. The arguments are combined with the get_children defaults and are then passed to the get_posts() function, which accepts additional arguments. You can replace the defaults in this function, listed below and the additional arguments listed in the get_posts() function.
The ‘post_parent’ is the most important argument and important attention needs to be paid to the $args parameter. If you pass either an object or an integer (number), then just the ‘post_parent’ is grabbed and everything else is lost. If you don’t specify any arguments, then it is assumed that you are in The Loop and the post parent will be grabbed for from the current post.
The ‘post_parent’ argument is the ID to get the children. The ‘numberposts’ is the amount of posts to retrieve that has a default of ‘-1’, which is used to get all of the posts. Giving a number higher than 0 will id="see-also" tabindex="-1">See also See also
User defined arguments for replacing the defaults.
Default value: ''
The required return type.>WP_Post object, an associative array, or a numeric array, respectively.
Default value: OBJECT
(WP_Post|int) Array of post objects or post IDs.