get_the_guid() WordPress Function

The get_the_guid() function in WordPress is used to retrieve the globally unique identifier (GUID) for a post. This function can be useful for plugins and themes that need to store data about a post in a global table or array.

get_the_guid( int|WP_Post $post ) #

Retrieves the Post Global Unique Identifier (guid).


Description

The guid will appear to be a link, but should not be used as an link to the post. The reason you should not use it as a link, is because of moving the blog across domains.


Top ↑

Parameters

$post

(int|WP_Post)(Optional) Post ID or post object. Default is global $post.


Top ↑

Return

(string)


Top ↑

Source

File: wp-includes/post-template.php

function get_the_guid( $post = 0 ) {
	$post = get_post( $post );

	$guid = isset( $post->guid ) ? $post->guid : '';
	$id   = isset( $post->ID ) ? $post->ID : 0;

	/**
	 * Filters the Global Unique Identifier (guid) of the post.
	 *
	 * @since 1.5.0
	 *
	 * @param string $guid Global Unique Identifier (guid) of the post.
	 * @param int    $id   The post ID.
	 */
	return apply_filters( 'get_the_guid', $guid, $id );
}


Top ↑

Changelog

Changelog
VersionDescription
1.5.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.