wp_get_shortlink


wp_get_shortlink ( $id = 0, $context = 'post', $allow_slugs = true )

Parameters:
  • (int) $id 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'.
  • (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.
Returns:
  • (string) A shortlink or an empty string if no shortlink exists for the requested resource or if shortlinks are not enabled.
Defined at:

Description

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

This function exists to provide a shortlink tag that all themes and plugins can target. A plugin must hook in to provide the actual shortlinks. Default shortlink support is limited to providing ?p= style links for posts. Plugins can short-circuit this function via the {@see 'pre_get_shortlink'} filter or filter the output via the {@see 'get_shortlink'} filter.

Related Functions

get_shortcut_link, wp_get_links, the_shortlink, get_author_link, wp_get_link_cats

Top Google Results

User discussions

wpseek mobile