WordPress 插件为主题提供页面模板
/* 加载页面模板 */
add_filter( 'page_template', 'marker_page_template' );
function marker_page_template( $page_template ) {
    if ( get_page_template_slug() == 'markerv' ) {
        $page_template = MARKER_DIR . '/templates/markerv.php';
    }
    if ( get_page_template_slug() == 'test' ) {
        $page_template = MARKER_DIR . '/templates/test.php';
    }
    return $page_template;
}

/* 添加到页面属性模板中 */
add_filter( 'theme_page_templates', 'marker_add_template_select', 10, 4 );
function marker_add_template_select( $post_templates, $wp_theme, $post, $post_type ) {
    $post_templates['markerv'] = __( 'markerv' );
    $post_templates['test'] = __( 'test' );
    return $post_templates;
}

模板文件:markerv.php

模板文件路径:/templates/markerv.php

显示在页面属性中的模板名称:$post_templates[‘markerv’] = __( ‘模板名称’);

收藏
评论
打赏
Composer 教程
上一篇
MarkerV 插件
下一篇
像素鱼丸
48334 阅读
88 发布
3 收藏
动态
MirageV 主题 2.16.2 发布
MirageV 主题 v2.6.4 发布
FishV 主题 v1.14 发布
LandV 企业主题 v2.6.0 发布
BotV 插件 v1.7.0 发布
MirageV 主题 v2.5 正式发布
FishV 主题 v1.21.0 发布
MirageV 主题 v2.6.0 发布
生成中...
真诚赞赏,手留余香
登录
注册
重置密码