精品人伦一区二区三区蜜桃视频_日韩精品视频在线_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
主站蜘蛛池模板: 久久亚洲国产 | 毛色毛片免费看 | 国产精品一区二区不卡 | 美女黄网 | 狠狠色网 | 色约约视频 | 中文字幕 在线观看 | 日本一区二区电影 | 在线色网 | 涩涩99 | 国产精品毛片一区二区在线看 | 亚洲国产成人在线观看 | 国产精品久久久久无码av | 久久成人精品一区二区三区 | 欧美中文字幕在线观看 | 午夜免费| 高清色视频 | 国产色| 一级欧美一级日韩片免费观看 | 91在线观看| 日韩一区不卡 | 欧美一级在线 | 中文字幕一区二区三区在线观看 | 在线播放中文字幕 | www在线视频 | 成年人精品视频 | 成人在线免费观看 | 久草网在线视频 | 欧美free性| 国产欧美一区二区三区在线看 | 亚洲a人 | 犬夜叉在线观看 | 久久久一二三 | 91精品国产91久久综合桃花 | 日韩在线精品 | 国产精品影视在线观看 | 亚洲视频一区二区三区 | 久久com| 一区二区精品在线 | 色婷婷久久久亚洲一区二区三区 | 欧美极品视频在线观看 |