免费在线观看污视频-亚洲精品永久免费-亚洲成a-日韩精品视频免费在线观看-黄色a网站-国产在线视频一区二区三区

CorePress使用插件的方式添加文章和頁面模板

網上的方法都比較麻煩,整理了一下代碼,只需要替換頁面名稱和頁面路徑即可

define('CP_PLUGIN_DIR', plugin_dir_path(__FILE__));
$cp_page_templates = array(
    array("slug" => "page-corepress.php",
        "name" => "CorePress-Pro主題頁面",
        "path" => CP_PLUGIN_DIR . "/page-corepress.php",
    ),
);
add_filter('page_template', 'cp_page_template');
add_filter('single_template', 'cp_page_template');
function cp_page_template($page_template)
{
    global $cp_page_templates;
    $slug = get_page_template_slug();
    foreach ($cp_page_templates as $item) {
        if ($slug == $item['slug']) {
            $page_template = $item['path'];
        }
        return $page_template;
    }
}
add_filter( 'theme_page_templates', 'cp_page_add_template_to_select', 10, 4 );
add_filter( 'theme_post_templates', 'cp_page_add_template_to_select', 10, 4 );

function cp_page_add_template_to_select( $post_templates, $wp_theme, $post, $post_type ) {
    global $cp_page_templates;
    foreach ($cp_page_templates as $item) {
        $post_templates[$item['slug']] = $item['name'];
    }
    return $post_templates;
}

其中,只需要修改$cp_page_templates變量里面的參數即可,slug為文件名稱,name為模板名稱,path為文件路徑。多個模板,多添加幾個array即可。

另外用的時候,建議也改一改常量CP_PLUGIN_DIR,改成唯一的名字。

 

THE END
主站蜘蛛池模板: 亚洲bt欧美bt国产bt | 综合欧美日韩一区二区三区 | 成人黄网大全在线观看 | 老司机亚洲精品 | 欧美一级特黄真人毛片 | 久草资源在线 | 国产精品6| 国产精品国产精品 | 欧美手机看片 | 成年人网站在线观看免费 | 国产成年女一区二区三区 | 日本成人在线视频网站 | 久久视频精品线视频在线网站 | 精品久久网站 | 欧美一级久久 | 亚洲第一区视频在线观看 | 亚洲欧美一区二区三区 | 国产精品免费大片 | 中文字幕在线观看一区二区 | 欧美在线一级毛片观看 | 欧美一级在线看 | 91精品国产高清久久久久久91 | 91精品久久久久 | 免费高清一级欧美片在线观看 | 波多野结衣在线观看3人 | 免费观看欧美精品成人毛片能看的 | aaa一级毛片 | 亚洲欧美日本人成在线观看 | 成年女人看片免费视频播放器 | 久久综合精品国产一区二区三区无 | 美女张开腿给人网站 | 欧美在线综合视频 | 可以免费看黄色的网站 | 国产深夜福利视频在线播放 | 亚洲rct中文字幕在线 | 欧美一级欧美一级毛片 | 亚洲精品中文字幕在线 | 玖草在线观看 | 青青视频国产依人在线 | 久久99亚洲网美利坚合众国 | 欧美精品高清在线观看 |