get_page_template_slug()

最后更新于:2021-11-26 11:14:29

get_page_template_slug( int|GC_Post$post=null)

Get the specific template filename for a given post.

参数

$post

(int|GC_Post) (Optional) Post ID or GC_Post object. Default is global $post.

Default value: null

响应

(string|false) Page template filename. 响应s an empty string when the default page template is in use. 响应s false if the post does not exist.

源文件

文件: gc-includes/post-template.php

function get_page_template_slug( $post = null ) {
	$post = get_post( $post );

	if ( ! $post ) {
		return false;
	}

	$template = get_post_meta( $post->ID, '_gc_page_template', true );

	if ( ! $template || 'default' === $template ) {
		return '';
	}

	return $template;
}