首页 WordPress函数大全 get_children()

get_children()

2020-05-01 / 2067阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

get_children( mixed $args = '', string $output = OBJECT )

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

  • get_posts()

Top ↑

参数

$args

(mixed)
(Optional)
User defined arguments for replacing the defaults.

Default value: ''

$output

(string)
(Optional)
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.

大家谈论
    我的见解