get_shortlink
Filters the shortlink for a post.
Usage
add_filter( 'get_shortlink', 'wp_kama_get_shortlink_filter', 10, 4 ); /** * Function for `get_shortlink` filter-hook. * * @param string $shortlink Shortlink URL. * @param int $id Post ID, or 0 for the current post. * @param string $context The context for the link. One of 'post' or 'query', * @param bool $allow_slugs Whether to allow post slugs in the shortlink. Not used by default. * * @return string */ function wp_kama_get_shortlink_filter( $shortlink, $id, $context, $allow_slugs ){ // filter... return $shortlink; }
- $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(true|false)
- Whether to allow post slugs in the shortlink. Not used by default.
Changelog
Since 3.0.0 | Introduced. |
Where the hook is called
get_shortlink
wp-includes/link-template.php 4177
return apply_filters( 'get_shortlink', $shortlink, $id, $context, $allow_slugs );