函数原型
get_post_permalink( int|WP_Post $post, bool $leavename = false, bool $sample = false ): string|false
函数描述
Retrieves the permalink for a post of a custom post type.
是否弃用
未弃用
函数参数
-
$post
int|WP_Post
Optional - Post ID or post object. Default is the global
$post. -
$leavename
bool
Optional - Whether to keep post name.
Default:
false -
$sample
bool
Optional - Is it a sample permalink.
Default:
false
函数返回值
string|false The post permalink URL. False if the post does not exist.
函数位置
File: wp-includes/link-template.php.
函数源码
<?php get_post_permalink( $id, $leavename, $sample ); ?>源码链接
变更日志
| Version | Description |
|---|---|
| 6.1.0 | Returns false if the post does not exist. |
| 3.0.0 | Introduced. |

