Skip to content
qnnp

WordPress 插件添加自定义页面模板文件

发布于: | 没有评论 | 分类:

add_filter( 
	'page_template', 
	function( $page_template ){
		if ( get_page_template_slug() == 'custom-template.php' ) {
			$page_template = __DIR__.'/custom-template.php';
		}
		return $page_template;
	}
);
add_filter(
	'theme_page_templates', function( $posts_templates ) {
		$posts_templates = array_merge( 
			$posts_templates, 
			array(
				'custom-template.php' => '模板名称',
			)
		);
		return $posts_templates;
	}
);

标签:

0 0 投票数
文章评分
订阅评论
提醒
guest
0 评论
内联反馈
查看所有评论

0
希望看到您的想法,请您发表评论x