wp_get_single_post()WP 1.0.0

Deprecated from version 3.5.0. It is no longer supported and can be removed in future releases. Use get_post() instead.

Retrieve a single post, based on post ID.

Has categories in 'post_category' property or key. Has tags in 'tags_input' property or key.

No Hooks.

Return

WP_Post|null. Post object or array holding post contents and information

Usage

wp_get_single_post( $postid, $mode );
$postid(int)
Post ID.
$mode(string)
How to return result, either OBJECT, ARRAY_N, or ARRAY_A.
Default: OBJECT

Examples

0

#1 Display the content of post 14:

<?php
$post_14 = wp_get_single_post( 14 );
echo $post_14->post_content;
?>
0

#2 Data returned in the array

ID((int))
Post ID.
post_author((int))
Author ID of the post.
post_date((string))
Date posts in the format YYYY-MM-DD HH:MM:SS (including time corrections).
post_date_gmt((string))
Date posts in the format YYYY-MM-DD HH:MM:SS (GMT).
post_content((string))
Text posts.
post_title((string))
Headline posts.
post_excerpt((string))
Quote posts.
post_status((string))
Statute posts, may be: publish|pending|draft|private|static|object|attachment|inherit|future|trash.
comment_status((string))
The ability to comment on posts, can be: open|closed|registered_only.
ping_status((string))
Ping/trackback status, can be: open|closed.
post_password((string))
Password posts.
post_name((string))
The name of the post (slug). The name that is usually used in the URL.
to_ping((string))
The URLs from the article to which you want to send notifications when you update the post.
pinged((string))
URLs from the article that have already received notifications.
post_modified((string))
Date of post changes in the format YYYY-MM-DD HH:MM:SS (with time correction).
post_modified_gmt((int)/(string))
Date of post changes in the format YYYY-MM-DD HH:MM:SS (Greenwich Mean Time (GMT)).
post_parent((int))
the ID of the parent page (different from zero for attached post types).
guid((string))
Link to the post. Important: Using this parameter as a permanent link for the post is wrong if your WordPress version is higher than 2.5. This is a unique post identifier that later became a link to the post.
menu_order((int))
The sequence number to build the menu (used for static pages).
post_type((string))
Post type (post|page|attachment).
post_mime_type((string))
Mime type of posts (jpg|png|zip|pdf, etc.). Used for pinned posts.
comment_count((int))
Number of comments on posts.
post_category(?)
The categories to which the post belongs.
tags_input(?)
Tags to which the post applies.

Notes

Changelog

Since 1.0.0 Introduced.
Deprecated since 3.5.0 Use get_post()

wp_get_single_post() code WP 6.5.2

function wp_get_single_post( $postid = 0, $mode = OBJECT ) {
	_deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' );
	return get_post( $postid, $mode );
}