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 评论