get_page_link
函数
get_page_link ( $post = false, $leavename = false, $sample = false )
- 参数
-
-
(int|WP_Post)
$post
Optional. Post ID or object. Default uses the global `$post`.- Required: 否
- Default: false
-
(bool)
$leavename
Optional. Whether to keep the page name. Default false.- Required: 否
- Default: false
-
(bool)
$sample
Optional. Whether it should be treated as a sample permalink. Default false.- Required: 否
- Default: false
-
(int|WP_Post)
- 返回值
-
- (string) The page permalink.
- 定义位置
-
-
wp-includes/link-template.php
, line 387
-
wp-includes/link-template.php
- 引入
- 1.5.0
- 弃用
- –
检索当前页面或页面ID的固定链接。
尊重page_on_front。使用这个。
function get_page_link( $post = false, $leavename = false, $sample = false ) { $post = get_post( $post ); if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) { $link = home_url( '/' ); } else { $link = _get_page_link( $post, $leavename, $sample ); } /** * Filters the permalink for a page. * * @since 1.5.0 * * @param string $link The page's permalink. * @param int $post_id The ID of the page. * @param bool $sample Is it a sample permalink. */ return apply_filters( 'page_link', $link, $post->ID, $sample ); }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。