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

wp_get_links, get_shortcut_link, the_shortlink, get_author_link, wp_shortlink_header

Top Google Results

User discussions

wpseek mobile