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

---

# apply_filters( ‘get_shortlink’, string $shortlink, int $id, string $context, bool $allow_slugs )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/get_shortlink/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/get_shortlink/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/get_shortlink/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/get_shortlink/?output_format=md#changelog)

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

Filters the shortlink for a post.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/get_shortlink/?output_format=md#parameters)󠁿

 `$shortlink`string

Shortlink URL.

`$id`int

Post ID, or 0 for the current post.

`$context`string

The context for the link. One of `'post'` or `'query'`,

`$allow_slugs`bool

Whether to allow post slugs in the shortlink. Not used by default.

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

    ```php
    return apply_filters( 'get_shortlink', $shortlink, $id, $context, $allow_slugs );
    ```

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

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

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

Returns a shortlink for a post, page, attachment, or site.

  |

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

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

## User Contributed Notes

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