Core Function
View Source on Trac ↗ wp_get_shortlink()
wp_get_shortlink( mixed $id = 0, mixed $context = 'post', mixed $allow_slugs = true ) Returns a shortlink for a post, page, attachment, or site.
Parameters 2 required
| Name / Type | Description |
|---|---|
| $id int | Optional. A post or site ID. Default is 0, which means the current post or site. |
| string | $context Optional. Whether the ID is a 'site' ID, 'post' ID, or 'media' ID. If 'post', the post_type of the post is consulted. If 'query', the current query is consulted to determine the ID and context. Default 'post'. Required |
| bool | $allow_slugs Optional. Whether to allow post slugs in the shortlink. It is up to the plugin how and whether to honor this. Default true. Required |
Return Value
(string)
string A shortlink or an empty string if no shortlink exists for the requested resource or if shortlinks
are not enabled.
Function Information
Since Version
3.0.0
Source File
wp-includes/link-template.php
Advertisement