首页 WordPress函数大全 get_post()

get_post()

2020-05-01 / 4409阅 / 悠然

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

get_post( int|WP_Post|null $post = null, string $output = OBJECT, string $filter = 'raw' )

Retrieves post data given a post ID or post object.

描述

See sanitize_post() for optional $filter values. Also, the parameter $post, must be given as a variable, since it is passed by reference.

参数

$post

(int|WP_Post|null)
(Optional)
Post ID or post object. Defaults to global $post.

Default value: null

$output

(string)
(Optional)
The required return type.>WP_Post object, an associative array, or a numeric array, respectively.

Default value: OBJECT

$filter

(string)
(Optional)
Type of filter to apply. Accepts 'raw', 'edit', 'db', or 'display'.

Default value: 'raw'

返回

(WP_Post|array|null) Type corresponding to $output on success or null on failure. When $output is OBJECT, a WP_Post instance is returned.

大家谈论
    我的见解