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

wp_get_single_post() WordPress Function

The wp_get_single_post() function allows you to retrieve a single post from the WordPress database. This function takes one parameter, the post ID, and returns the corresponding post object.

wp_get_single_post( int $postid, string $mode = OBJECT ) #

Retrieve a single post, based on post ID.


Description

Has categories in ‘post_category’ property or key. Has tags in ‘tags_input’ property or key.

Top ↑

See also


Top ↑

Parameters

$postid

(int)(Required)Post ID.

$mode

(string)(Optional)How to return result, either OBJECT, ARRAY_N, or ARRAY_A.

Default value: OBJECT


Top ↑

Return

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


Top ↑

Source

File: wp-includes/deprecated.php

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


Top ↑

Changelog

Changelog
VersionDescription
3.5.0Use get_post()
1.0.0Introduced.

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