11
Nov
Posted by iStef as WordPress Tips
WordPress 2.3 已经推出一段时间了,但是很多朋友还没有升级。撇开插件问题不谈,另一个比较麻烦的问题就是现有模板的问题。其实相比插件,模板的不兼容问题很少(K2 那类过于强大的除外),只是无法支持新的 Tag 系统而已。Sadish 的一篇文章指出了如何通过简单的方法来让现有模板支持 WordPress 2.3 的 Tag 系统,简单总结一下:
- 显示文章的 Tag:在模板中找到 <?php the_content() ?> 或者 <?php the_excerpt();?>,在其后添加:
<p><?php if (function_exists(’the_tags’)) the_tags(’Tags: ‘, ‘, ‘, ‘<br/>’);?></p>
这样就可以在每篇文章后显示 Tags 了。实际上就是在 WP_LOOP 中调用 the_tags 函数。当然,对于那些仍然使用 start_wp() 而不是 the_post() 函数的古董级模板,这招无效。
- 显示标签云:在 sidebar.php 中找个合适的地方,写入:
<?php if (function_exists(’wp_tag_cloud’)) { ?>
<li>
<h2><?php _e(’Tags’); ?></h2>
<p>
<?php wp_tag_cloud(); ?>
</p>
</li>
<?php } ?>
就可以显示标签云了。
- 显示 Tag 汇整页面:打开 archive.php 页面,写入:
<?php if (function_exists(’is_tag’)&& is_tag()) { ?>
<h2>Archive for the Tag ‘<?php echo single_tag_title(); ?>’</h2>
<?php } ?>
完工:)
3 Responses
yuhuashi
November 22nd, 2007 at 4:17 pm
1这个代码很实用
http://www.yuhuashi.org
日记本本
November 25th, 2007 at 5:24 pm
2学习了
日记本本的特性
● 完全基于Wordpress改造,保留所有功能
● 模板众多,轻轻一点,界面全换
● 独特的拼音文件名功能,修正了wordpress在中文下的地址问题
● 数据库特殊优化,保证多用户的稳定性
● 全页面缓存,速度更快
● 所有wordpress优良的特性
● 演示日记本: http://ykjsw.rijibb.com
badblue
December 7th, 2007 at 9:35 pm
3想想还是2。2好呀!
RSS feed for comments on this post · TrackBack URI
Leave a reply
Categories
本站福利
优惠代码:KDOLPHIN
Recent Comments