get_permalink()
get_permalink( int|WP_Post $post, bool $leavename = false )
检索当前文章或文章ID的完整永久链接。
Retrieves the full permalink for the current post or post ID.
参数(Parameters)
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
$post | (int | WP_Post) | 可选 | Post ID或Post对象。默认值为全局$post。 |
$leavename | (bool) | 可选 | 是保留文章名还是页面名。 |
返回(Return)
(string|false)永久链接URL,如果post不存在则为false。
源码(Source)
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
1.0.0 | wp-includes/link-template.php:119 | 66 | 18 |
笔记(Notes)
传入post对象而不是ID
通过slug获取post或page(或其他)permalink:
默认用法
get_permalink() 为WP2原创文章,链接:https://www.wp2.cn/functions/get_permalink/