WordPress修改记录和技巧
本站使用的插件:
Google XML Sitemaps 生成网站地图,基本上是必需的。
Yet Another Related Posts Plugin 文章相关插件,功能挺好的,可惜我不懂修改模板,所以放弃了没用。
Comment Reply Notification 评论回复通知插件, 当评论被回复时会email通知评论的作者.
My Category Order 提供分类目录排序功能,wordpress本身自带的分类目录没有得排序。
My Link Order 友情链接排序
WordPress Related Posts 文章相关插件
WP-PageNavi 分页插件
Widget Logic 调整侧边栏在页面中显示什么,例如我的友情链接,就只在首页中显示,其他不显示。
Super Switch 超级开关,可以禁用某些功能,例如修订历史、检查更新等
All in One SEO SEO插件,实在不知道用那个好
技巧
[主题] 如何在博客 index 页面显示文章摘要, 而非文章的全部内容?
方法有二:
1. 打开 index.php 文件, 找到 the_content, 并将 the_content(...) 改成 the_excerpt().
2. 在撰写文章的时候在文章内加入 标签 (请注意添加位置, 以免造成页面缺失标签), Visual 编辑模式下可以点击 'Insert More tag' 按钮 (快捷键 Alt+Shift+T) 添加.
禁用修订历史
在wordpress的程序根目录,配置文件wp-config.php中
1 2 3 4 5 6 7 | /**
* WordPress 编辑器自动保存和历史版本选项。
*
* 本项注释掉即可开启。
*/
define('WP_POST_REVISIONS', false);//禁用历史修订版本
define('AUTOSAVE_INTERVAL', 86400);//设置自动保存时间设置为一天。 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* external links START */ .post .content a[href^="http:"]{ background: url(external.png) no-repeat right; padding-right:12px; } .post .content a[href^="http://hillboy.org"],.post .content a[href^="http://hillboy.org"],.post .content a[href^="http://picasaweb.google.com"]{ background-image:none; padding-right:0; } .post .content a[href$=".jpg"],.post .content a[href$=".gif"]{ background-image:none; padding-right:0; } /* external links END */ |
WP Super Cache 功能强大的缓存插件
卸载方法:
禁用插件。
删除/wp-content/plugins/wp-super-cache目录。
删除/wp-content/cache目录。
如果出现以下提示
UNINSTALL_WPSUPERCACHE must be set to a non-blank value in uninstall.php
需要在WP Super Cache插件安装目录下找到uninstall.php文件,
将define( ‘UNINSTALL_WPSUPERCACHE’, ”);
改为define( ‘UNINSTALL_WPSUPERCACHE’, ‘1′ );
删除wp-content目录下的wp-config.php、advanced-cache.php文件。
修改站点根目录下的wp-config.php,删掉 define(’WP_CACHE’, true);
重建.htaccess文件。
防止wordpress英文标点符号半角转全角
最近发代码的时候Wordpress总是在前面访问的时候把英文的标点符号从半角转为全角.这样看代码和复制代码的时候就带来了困难了..
解决方法:
修改位于”WordPress安装目录/wp-includes/”目录里面的”formatting.php”文件, 在第25行到第43行的这个for循环语句的第一个if条件里, 你应该能看到以下4行代码(或者你直接搜索这些代码查找也可以):
1 2 3 4 5 | // static strings $curl = str_replace($static_characters, $static_replacements, $curl); // regular e-xpressions $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); } |
将这个if条件里面的两个 $curl = 开头的行都屏蔽就可以了, 如下:
1 2 3 4 5 | // static strings // 屏蔽自动转换标点 $curl = str_replace($static_characters, $static_replacements, $curl); // regular e-xpressions // 屏蔽自动转换标点 $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); } |
然后保存好后, 重新刷新你的页面, 那些英文标点就不会在被自动转换为中文标点了.
调整标签字体大小
修改目录wp-includes/category-template.php文件
查找smallest' => 8, 'largest' => 22
默认最小和最大字体为8和22,这个自己喜欢改,我就改成最大16。
给 WordPress 留言框添加背景文字
在 css 文件中找到留言框的属性定义语句,比如我的是:
1 2 3 | textarea#comment { width:651px; } |
改成
1 2 3 4 | textarea#comment { width:651px; background:url(images/liuyang.png) no-repeat scroll center center; } |
301转向
完美301跳转,带www和不带www均可跳转。
1 2 3 4 5 6 7 8 9 10 11 12 | # BEGIN WordPress
<ifmodule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^nhljz.net$ [OR]
RewriteCond %{HTTP_HOST} ^www.nhljz.net$
RewriteRule ^(.*)$ http://hillboy.org/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</ifmodule>
# END WordPress |
修改可以将 评论 Email 通知中的 IP Whois 查询链接
打开 wp-includes\pluggable.php
查找:(共两处,分别在953行,1048行)
http://ws.arin.net/cgi-bin/whois.pl?queryinput=
替换为:
http://www.ip138.com/ips.asp?ip=
JS实现延迟加载
1 2 3 4 5 6 7 8 9 10 11 | <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.lazyload.js"></script>
<script type="text/javascript">
jQuery(document).ready(
function($){
$("img").lazyload({
placeholder : "< ?php bloginfo('template_url'); ?>/js/grey.gif",
effect : "fadeIn"
});
});
</script> |
