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

---

# apply_filters( ‘pre_get_shortlink’, false|string $return, int $id, string $context, bool $allow_slugs )

## In this article

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

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

Filters whether to preempt generating a shortlink for the given post.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/pre_get_shortlink/?output_format=md#description)󠁿

Returning a value other than false from the filter will short-circuit the shortlink
generation process, returning that value instead.

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

 `$return`false|string

Short-circuit return value. Either false or a URL string.

`$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.

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

    ```php
    $shortlink = apply_filters( 'pre_get_shortlink', false, $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#L4167)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/link-template.php#L4167-L4167)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/pre_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/pre_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%2Fpre_get_shortlink%2F)
before being able to contribute a note or feedback.