精品人伦一区二区三区蜜桃视频_日韩精品视频在线_www.色综合_久久久久久一区_aaaaaa黄色片_亚洲精品久久

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

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

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變量里面的參數(shù)即可,slug為文件名稱,name為模板名稱,path為文件路徑。多個模板,多添加幾個array即可。

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

 

THE END
主站蜘蛛池模板: 日韩中文字幕视频在线观看 | 成人午夜免费福利视频 | 成人精品一区 | 亚洲视频免费在线观看 | 色爱综合 | 国产精品1区2区3区 一区中文字幕 | 二区国产| 久久久成人一区二区免费影院 | 国产伦精品一区二区三区照片91 | 日日骚视频 | 三级视频久久 | 久久婷婷国产麻豆91 | 久久久精品亚洲 | 久久久久国产精品午夜一区 | 一级黄色片毛片 | 999久久久久久久 | 天天躁日日躁xxxxaaaa | 国产精品1区 | 国产一级片一区二区 | 欧美视频免费在线观看 | 久久一区精品 | 亚洲电影一区二区三区 | 久久久久久久久淑女av国产精品 | 日韩欧美中文在线 | 日韩欧美国产成人一区二区 | 亚洲一区二区不卡在线观看 | 久久久网 | 亚洲高清久久 | 天堂一区 | 日韩视频在线免费观看 | 在线观看a视频 | 欧美激情综合五月色丁香小说 | 久久久.com | 成人午夜电影在线观看 | 成人在线免费观看 | 精品9999| 日韩免费一区 | 色婷婷综合久久久中文字幕 | 黄色免费在线网址 | 亚洲精品久久久一区二区三区 | 日本在线看 |