wpseek.com
WordPress开发者和主题制作者的搜索引擎



get_page_template_slug › WordPress Function

Since3.4.0
已弃用n/a
get_page_template_slug ( $post = null )
参数:
  • (int|WP_Post) $post Optional. Post ID or WP_Post object. Default is global $post.
    Required: No
    默认: null
返回:
  • (string|false) Page template filename. Returns an empty string when the default page template is in use. Returns false if the post does not exist.
定义在:
文档:
Change Log:
  • 4.7.0

Gets the specific template filename for a given post.



源码

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

	if ( ! $post ) {
		return false;
	}

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

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

	return $template;
}