On this page
get_the_guid( int|WP_Post $post ): string
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.
Parameters
$postint|WP_Post Optional-
Post ID or post object. Default is global $post.
Return
string
Source
File: wp-includes/post-template.php. View all references
function get_the_guid( $post = 0 ) {
$post = get_post( $post );
$post_guid = isset( $post->guid ) ? $post->guid : '';
$post_id = isset( $post->ID ) ? $post->ID : 0;
/**
* Filters the Global Unique Identifier (guid) of the post.
*
* @since 1.5.0
*
* @param string $post_guid Global Unique Identifier (guid) of the post.
* @param int $post_id The post ID.
*/
return apply_filters( 'get_the_guid', $post_guid, $post_id );
}
Hooks
- apply_filters( 'get_the_guid',
string $post_guid ,int $post_id ) -
Filters the Global Unique Identifier (guid) of the post.
Related
Uses
| Uses | Description |
|---|---|
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| get_post() wp-includes/post.php | Retrieves post data given a post ID or post object. |
Used By
| Used By | Description |
|---|---|
| get_comment_guid() wp-includes/feed.php | Retrieves the feed GUID for the current comment. |
| the_guid() wp-includes/post-template.php | Displays the Post Global Unique Identifier (guid). |
| _transition_post_status() wp-includes/post.php | Hook for managing future post transitions to published. |
| wp_get_attachment_url() wp-includes/post.php | Retrieves the URL for an attachment. |
Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_the_guid