[英]Wordpress Custom Post Template
I'm trying to get Wordpress to include a different template file, within single.php, if it sees a file matching the slug. 我试图让Wordpress在single.php中包含一个不同的模板文件,如果它看到一个与该文件匹配的文件。
The file does exits, path is correct, safe_mode set to OFF...am I missing something? 文件确实退出,路径正确,safe_mode设置为OFF ...我丢失了什么吗?
$dir=get_bloginfo('stylesheet_directory').'/post_tmpl/';
$categories=get_categories();
foreach($categories as $cat){
if(is_file($dir.$cat->slug.".php")){
require($dir.$cat->slug.".php");
}else{
require($dir."default.php");
}
}
can you try with this code? 您可以尝试使用此代码吗?
$dir=get_bloginfo('stylesheet_directory').'/post_tmpl/';
$categories=get_categories();
foreach($categories as $cat){
$temp = $dir.$cat->slug;
if(is_file($temp.".php")){
require($temp.".php");
}else{
require($dir."default.php");
}
}
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.