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

get_postdata() WordPress Function

The get_postdata() function is used to get the data for a post from the WordPress database. This function is used by the WordPress loop to display posts.

get_postdata( int $postid ) #

Retrieves all post data for a given post.


Description

Top ↑

See also


Top ↑

Parameters

$postid

(int)(Required)Post ID.


Top ↑

Return

(array) Post data.


Top ↑

Source

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;
}


Top ↑

Changelog

Changelog
VersionDescription
1.5.1Use get_post()
0.71Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More