the_guid

Display the Post Global Unique Identifier (guid).

Description

the_guid( (int) $post = 0 ); 

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

URL is escaped to make it XML-safe.

Parameters (1)

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

Usage

  1. if ( !function_exists( '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 = the_guid($post); 
  9.  

Defined (1)

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

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