检索给定帖子的所有帖子数据。

原型

get_postdata( int $postid )

参数

$postid (int) (Required) 帖子ID。

返回值

(array)  发布数据。

源文件

路径:wp-includes/deprecated.php

<?php
...
function get_postdata($postid) {
	_deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' );
	$post = get_post($postid);
	$postdata = array (
		'ID' => $post->ID,
		'Author_ID' => $post->post_author,
		'Date' => $post->post_date,
		'Content' => $post->post_content,
		'Excerpt' => $post->post_excerpt,
		'Title' => $post->post_title,
		'Category' => $post->post_category,
		'post_status' => $post->post_status,
		'comment_status' => $post->comment_status,
		'ping_status' => $post->ping_status,
		'post_password' => $post->post_password,
		'to_ping' => $post->to_ping,
		'pinged' => $post->pinged,
		'post_type' => $post->post_type,
		'post_name' => $post->post_name
	);
	return $postdata;
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/get_postdata/