钩子文档

get_shortlink

💡 云策文档标注

概述

get_shortlink 是一个 WordPress 过滤器,用于修改文章、页面、附件或站点的短链接 URL。它允许开发者在生成短链接时自定义输出。

关键要点

  • 过滤器名称:get_shortlink
  • 参数:$shortlink(短链接 URL)、$id(文章 ID)、$context(上下文,如 'post' 或 'query')、$allow_slugs(是否允许使用文章别名)
  • 相关函数:wp_get_shortlink() 用于获取短链接
  • 引入版本:WordPress 3.0.0

📄 原文内容

Filters the shortlink for a post.

Parameters

$shortlinkstring
Shortlink URL.
$idint
Post ID, or 0 for the current post.
$contextstring
The context for the link. One of 'post' or 'query',
$allow_slugsbool
Whether to allow post slugs in the shortlink. Not used by default.

Source

return apply_filters( 'get_shortlink', $shortlink, $id, $context, $allow_slugs );

Changelog

Version Description
3.0.0 Introduced.