Title: get_self_link
Published: November 12, 2019
Last modified: February 24, 2026

---

# get_self_link(): string

## In this article

 * [Return](https://developer.wordpress.org/reference/functions/get_self_link/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_self_link/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/get_self_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_self_link/?output_format=md#changelog)

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

Returns the link for the currently displayed feed.

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

 string Correct link for the atom:self element.

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

    ```php
    function get_self_link() {
    	$parsed = parse_url( home_url() );

    	$domain = $parsed['host'];
    	if ( isset( $parsed['port'] ) ) {
    		$domain .= ':' . $parsed['port'];
    	}

    	return set_url_scheme( 'http://' . $domain . wp_unslash( $_SERVER['REQUEST_URI'] ) );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/feed.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/feed.php#L670)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/feed.php#L670-L679)

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

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

Sets the scheme for a URL.

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

Removes slashes from a string or recursively removes slashes from strings within an array.

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

Retrieves the URL for the current site where the front end is accessible.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/get_self_link/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_self_link/?output_format=md#)

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

Displays the link for the currently displayed feed in a XSS safe way.

  |

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

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

## User Contributed Notes

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