wordpress给单篇文章设置模板

有时候你会想给某篇文章单独设置个模板或者加一段内容,比如一段PHP代码,又不想或者就不能直接加在文章里,就可以在模板的single.php中加入is_single() 函数。

比如:<php if ( is_single(’265′)  ) { include (‘special.php’); } ?>

注意开头php那里少了个?,这句话就是对ID为265的文章加入special.php里的内容。

将这句话放在single.php里的某个位置,然后在模板文件夹里新建一个special.php的文件,加入需要的内容就行了。

更多函数的使用,请参考 Conditional Tags

还有篇讲模板技巧的

Popularity: 9% [?]


Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Copyright © 2010 时光漫步. All rights reserved.
Powered by WordPress.org, Custom Theme and ComFi.com Calling Card Company.