精品人伦一区二区三区蜜桃视频_日韩精品视频在线_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
主站蜘蛛池模板: 国产精品精品久久久 | 久久综合成人精品亚洲另类欧美 | 午夜影院在线观看 | 日韩欧美中文 | 国产jizz女人多喷水99 | 精品国产99 | 99久久99| 国产一区二区三区视频 | 欧美电影免费观看高清 | 中文字幕高清视频 | 亚洲资源在线 | 夜夜夜久久久 | 女生羞羞网站 | 一区二区三区免费 | 久久精品国产久精国产 | 亚洲福利网站 | 涩涩视频在线观看免费 | www.日韩 | 欧美精品1区 | 99免费在线观看 | 中文字幕国产视频 | 亚洲国产aⅴ精品一区二区 免费观看av | 亚洲综合国产 | 亚洲综合色视频在线观看 | www日本在线播放 | 国产高清久久 | 日本亚洲欧美 | 日韩一区二区视频 | 国产羞羞视频在线观看 | 国产黄色大片 | 麻豆av免费观看 | 亚洲一区二区在线视频 | 久久一 | 成人看片在线观看 | 完全免费在线视频 | 欧美成人高清视频 | 性高朝久久久久久久3小时 av一区二区三区四区 | 在线亚洲精品 | 成人在线中文字幕 | 欧美视频偷拍 | 懂色av一区二区三区在线播放 |