让不同分类下的单篇志使用不同的模
效果提示:如果你厌烦了分类下的单篇文章都使用同一个(single。
php)模板。
那么这个方法可以让你达到让不同分类使用不同的单篇文章模板。
方法:使用incategory函数来判断某篇日志处于哪个目录,然后调用不同的单篇日志模板。
在默认的single。
php文件中,敲入下面的代码$post=$wpquery->post;if(incategory(’1′)){include(templatepath。
‘single1。
php’);}elseif(incategory(’2′)){include(templatepath。
‘single2。
php’);}else{include(templatepath。
‘singleother。
php’);}?>以上代码说明:目录1的文章将使用single1。
php模板,目录2的文章将使用single2。
php,其它文章将使用singleother模板。
来自:理处言语然自
本章未完,点击下一页继续阅读
返回顶部