我目前正在为客户端构建一个站点,该站点集成在WordPress中。该网站分为两部分。一个是网站的公共区域,另一个是仅供会员使用的客户区域。最后一个我已经意识到的插件PA登录&从Codecanyon访问。
我在想,在我的示例downloads, timesheets and events中,您是否可以为一系列定制的post类型使用一个模板。因此,这3种定制的post类型使用相同的模板。
谢谢。卡斯珀
发布于 2014-11-25 22:08:30
您可以使用类似的内容指向您想要的单个模板的文件。
add_filter( 'template_include', 'change_template', 1, 5 );
public function change_template($template_path) {
    if( get_post_type() == 'myposttype' ||  get_post_type() == 'myanotherposttype' ):
        if( is_single() ):  
                $template_path = 'full path to your file.php';
        endif;      
    endif;
    return $template_path;
}https://stackoverflow.com/questions/27124559
复制相似问题