get_postdata() - WordPress 函数参考中文文档

返回介绍

get_postdata()

发布于 2017-09-10 字数1836 浏览 1015 评论 0

Warning: This function has been deprecated. Use get_post() instead.

get_postdata( int $postid )

Retrieves all post data for a given post.


描述


参数

$postid

(int)
(Required)
Post ID.


返回值

(array) Post data.


源代码

File: wp-includes/deprecated.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;
}

更新日志

Version 描述
1.5.1 Use get_post()
0.71 Introduced.

相关函数

Uses

  • wp-includes/functions.php:
    _deprecated_function()
  • wp-includes/post.php:
    get_post()

User Contributed Notes

上一篇:get_post()

下一篇:get_posts()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!