get_the_guid

Retrieve the Post Global Unique Identifier (guid).

Description

(string) get_the_guid( (int) $post = 0 ); 

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.

Returns (string)

Parameters (1)

0. $post — Optional. (int)
Post ID or post object. Default is global $post.

Usage

  1. if ( !function_exists( 'get_the_guid' ) ) { 
  2. require_once ABSPATH . WPINC . '/post-template.php'; 
  3.  
  4. // Optional. Post ID or post object. Default is global $post. 
  5. $post = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_the_guid($post); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/post-template.php  
  1. function get_the_guid( $post = 0 ) { 
  2. $post = get_post( $post ); 
  3.  
  4. $guid = isset( $post->guid ) ? $post->guid : ''; 
  5. $id = isset( $post->ID ) ? $post->ID : 0; 
  6.  
  7. /** 
  8. * Filters the Global Unique Identifier (guid) of the post. 
  9. * @since 1.5.0 
  10. * @param string $guid Global Unique Identifier (guid) of the post. 
  11. * @param int $id The post ID. 
  12. */ 
  13. return apply_filters( 'get_the_guid', $guid, $id );