事实上template_redirect
, 您可以将其放入函数中。php文件-以下是我使用的内容:
function uniquename_default_template() {
if(get_post_type() == \'posttype\') : /* You could use is_single() instead of get_post_type() == \'\' or any type of conditional tag) */
include(TEMPLATEDIR . \'path/to/theme/file.php\'); /* You could use TEMPLATEDIR to get a file from a template folder, or PLUGINDIR to get a file from the plugins directory - doesn\'t support HTTP requests */
exit; endif;
}
add_action(\'template_redirect\', \'uniquename_default_template\');
上述代码检查
post_type
调用
posttype
, 如果是,它将通过使用
template_redirect
作用