Title: get_the_guid
Published: April 25, 2014
Last modified: May 20, 2026

---

# get_the_guid( int|WP_Post $post ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#wp--skip-link--target)

Retrieves the Post Global Unique Identifier (guid).

## 󠀁[Description](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#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](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#parameters)󠁿

 `$post`int|[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)
optional

Post ID or post object. Default is global $post.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#return)󠁿

 string

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#source)󠁿

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

    	$post_guid = $post->guid ?? '';
    	$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 );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/post-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/post-template.php#L221)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/post-template.php#L221-L236)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#hooks)󠁿

 [apply_filters( ‘get_the_guid’, string $post_guid, int $post_id )](https://developer.wordpress.org/reference/hooks/get_the_guid/)

Filters the Global Unique Identifier (guid) of the post.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#related)󠁿

| Uses | Description | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_post()](https://developer.wordpress.org/reference/functions/get_post/)`wp-includes/post.php` |

Retrieves post data given a post ID or post object.

  |

| Used by | Description | 
| [get_comment_guid()](https://developer.wordpress.org/reference/functions/get_comment_guid/)`wp-includes/feed.php` |

Retrieves the feed GUID for the current comment.

  | 
| [the_guid()](https://developer.wordpress.org/reference/functions/the_guid/)`wp-includes/post-template.php` |

Displays the Post Global Unique Identifier (guid).

  | 
| [_transition_post_status()](https://developer.wordpress.org/reference/functions/_transition_post_status/)`wp-includes/post.php` |

Hook for managing future post transitions to published.

  | 
| [wp_get_attachment_url()](https://developer.wordpress.org/reference/functions/wp_get_attachment_url/)`wp-includes/post.php` |

Retrieves the URL for an attachment.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#changelog)󠁿

| Version | Description | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/get_the_guid/?output_format=md#comment-content-7496)
 2.   [jesus0903](https://profiles.wordpress.org/jesus0903/)  [  2 months ago  ](https://developer.wordpress.org/reference/functions/get_the_guid/#comment-7496)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_the_guid%2F%23comment-7496)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_the_guid%2F%23comment-7496)
 4. Although “GUID” stands for Globally Unique Identifier, WordPress does not enforce
    a uniqueness constraint on the database level. In some cases—particularly when 
    using plugins that publish posts without going through a draft state—multiple posts
    may share the same GUID value.
 5. You should not use the GUID as a unique key for querying posts. Instead, use the
    post ID to guarantee uniqueness.
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_the_guid%2F%3Freplytocom%3D7496%23feedback-editor-7496)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_the_guid%2F)
before being able to contribute a note or feedback.