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

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
主站蜘蛛池模板: 理论片87福利理论电影 | 91精品国产91综合久久蜜臀 | 欧美一区二区免费 | 免费在线观看h片 | 久久久久1| 福利视频一区 | 久久久91| 免费日韩av网站 | 亚洲精品免费视频 | 怡红院成人在线视频 | 精品一区二区三区免费毛片 | 手机看片1 | 日日天天 | 91.色| 日韩精彩视频 | 成人欧美一区二区三区黑人孕妇 | 亚洲欧美综合 | 亚洲一级毛片 | 小草久久久久久久久爱六 | 亚洲视频免费 | 国产激情一区二区三区 | 黄色片免费| 在线欧美一区 | 午夜视频在线 | 欧美不卡一区 | 日韩视频一区 | 精品久久国产视频 | 午夜在线精品偷拍 | 国产精品久久久久久一区二区三区 | 国精产品一品二品国精在线观看 | 欧美精品乱码久久久久久按摩 | 久久久久久久一级 | 成人精品久久日伦片大全免费 | 国产一区亚洲二区三区 | 91久久精品日日躁夜夜躁国产 | 黄色在线观看网址 | 免费午夜视频在线观看 | 亚洲精品亚洲人成人网 | 久久极品| 91爱啪啪| 免费日韩av |