1.为每个类别自定义样式
根据模板层级规定,wordpress会在当前主题文件中按顺序查找以下文件:
- category-6.php
- category.php
- archive.php
- index.php
所以,如果想更改category id为6的文件,在主题文件夹里单独创建一个category-6.php就OK.
参考:设置分类页面 from:http://www.wordpress.la
2.wordpress 中文截断 无插件的实现方法
wordpress里自带的函数the_excerpt()不支持中文截断。下面是一个不用插件实现中文截断的方法,很好用!
在模板中找到:
1
2
3 <?php the_content(); ?>
或者
<?php the_excerpt();?>
替换为:
1 <?php echo mb_strimwidth(strip_tags(apply_filters(’the_content’, $post->post_content)), 0, 300,”…”);?>
300为截断的中文数字。
参考:无插件wordpress中文截断
推荐阅读:
原创文章,转载请注明: 转载自wordpress公园
本文链接地址: wordpress theme tips
随机日志
已经有Please wait人阅读了本文







发现那段长长的突出的代码,我的心里一阵怨念!
补充:strip_tags函数是清除html tag.
mb_strimwidth($string,$start,$width,$trimarker)
$string是需要截取宽度的字符串。$start是从字符串的第几个字符开始数宽度。第一个从0开始数。$width是宽度。$strmarker是$width以后的字符用符号被替代。