Posts tagged wordpress
W3 Total Cache对Nginx的静态链接支持
4W3 Total Cache是wordpress一个很全面很强大的缓存加速插件 用了它之后其他什么优化插件都可以不需要了
它本身支持好几种缓存的方式 一般shared host就是网站空间的话 大概只能选disk缓存方式
我这个是vps 所以可以装php-apc用来缓存 ubuntu下也很方便 直接 sudo apt-get install php-apc就可以
类似的 依然还会有静态链接和nginx的配合问题 其实W3 Total Cache目前的版本已经支持nginx
配置好后 会在服务器wordpress的根目录下生成一个nginx.conf文件 所以需要做的只是把这段规则加到nginx的配置文件里就行
比如我nginx的配置文件是 /etc/nginx/sites-enabled/default 只需要在
server {
}
段里面location / 后面加上一段 变成这样就可以了
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.html;
if (!-e $request_filename) {
rewrite ^([_0-9a-zA-Z-]+)?(/wp-.*) $2 last;
rewrite ^([_0-9a-zA-Z-]+)?(/.*.php)$ $2 last;
rewrite ^ /index.php last;
}
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
include /var/www/wordpress/nginx.conf;
/var/www/wordpress相应改成wordpress文件的目录就行
nginx里wordpress 3.1的url rewrite规则
0整了一个vps 自己装上Nginx + PHP + Spawn-fcgi + MySQL 来放自己的博客
wordpress本身的静态化链接用的是Apache的mod_rewrite 都写在.htaccess文件里
但是nginx是不认这个的 用的是自己的一套规则 所以得自己添加进去一段
ubuntu下面直接修改的/etc/nginx/sites-enabled/default 里面 修改下面这些部分 就可以了
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.html;
if (!-e $request_filename) {
rewrite ^([_0-9a-zA-Z-]+)?(/wp-.*) $2 last;
rewrite ^([_0-9a-zA-Z-]+)?(/.*.php)$ $2 last;
rewrite ^ /index.php last;
}
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
当然了 我这里是直接用顶级域名放的博客 如果你是放在某个后缀里面的就把 location / 改成相应的后缀就行
加上上面这段就可以在后台选择固定链接了
装了个All-in-one SEO plugin害得Google跟Baidu都不收录我的博客了
1该死的插件 默认不收录所有的archives 结果我日志的所有链接都是archives/%post_id% 一篇都没被检索进去
Blogbus搬家到WordPress的Python转换脚本修改版 支持tags/分类导入
28(2010.1.17 Update: 写此文的时候我用的wordpress版本是2.8.4 导入是没有任何问题的
据几位同学反映wordpress升级到2.9以后评论的格式有了一点改变 具体讨论参见下面的评论
因此需要说明 我修改的脚本适用于wordpress 2.8版本 如果已升级到2.9 请前往这里下载新的版本bus2wp.py)
一时心血来潮 想把内容从blogbus都转过来 于是在网上搜索了一番
似乎这里http://blog.huyo.org/?p=336的python脚本是能转换最多的
php的转换脚本我也看了下 其实大同小异 只不过流传的那个脚本在我的Snow Leopard自带PHP 5.3下会产生一堆warning 没办法跑起来
对比了一下blogbus和wordpress(现在是2.8.4)的xml格式 就大概知道应该怎么构造xml了
python脚本里直接把blogbus里面的tags全部转换成wp里的category了 比较囧 我导完一次多出来几百个分类
似乎是因为当时wp的xml还没有正式支持tag和category
研究了一下wp的xml格式之后发现修改很简单 只需要加上
<category domain=”category”><![CDATA[Your Category]]></category>
<category domain=”tag”><![CDATA[Your Tag]]></category>
<category domain=”tag”><![CDATA[Your Tag]]></category>
就可以了
本身Python我没有怎么接触过 不过照葫芦画瓢还是可以改改
修改好的版本在这里下载: bus2wp_modified
留了个自己id 希望原作者ant21不介意 ![]()
对这个主题做的修改
0这个wordpress的主题叫做 colorpaper 感觉很好
用上去之后发现了好几个问题 花了一些时间做了修改 算是把功能都完善了
默认的index.php里对第一篇文章 即出现在最上面featured区域的文章
取的是最新的一篇blog文章 但是没有对文章内容做长度截断 这样导致文章过长时会直接挤到下面影响到下一篇文章
解决办法是在functions.php里加入一个get_string_limit函数 截断string到指定长度
function get_string_limit($output, $max_char)
{
$output = str_replace(‘]]>’, ‘]]>’, $output);
//$output = strip_tags($output);
if ((strlen($output)>$max_char) && ($espacio = strpos($output, ” “, $max_char ))){
$output = substr($output, 0, $espacio).’…’;
return $output;
}
else
{
return $output;
}
}
在index.php里将相应的the_content(”)修改为echo get_string_limit(get_the_content(”),600)即可
另外该主题提供了额外的sidebar板块 包括一个About 一个flickr相册显示 还有一个ajax tab
在sidebar.php里 如果之前在后台自己定义了sidebar widgets的话 模板修改的板块是不显示的
将代码稍作修改即可同时显示 但是我发现ajax tab这个板块没有相应的javascript代码进行操作 于是自己写了一段代码实现其hover效果
还有就是这个ajax tab使用的featured部分似乎跟我的All-in-one SEO插件有冲突 会把所有页面的title都修改为featured category | blog name 这个样子 无奈之下我只好把它改成显示最新文章了…
如果有空的话 我计划把这个模板按照dynablue的方法改写featured content部分 利用一个叫做Feature Me的插件来自由选择把哪些文章放到最上面那一栏 还可以实现slider的效果
我把修改好的版本打了包 喜欢用的自己拿去把 我顺便把里面的jquery也升级到1.3.2了
下载地址colorpaper
原来wordpress2.7之后就自带了thread comments了
2怪不得找了几个plugin都不能用 看来wordpress从2.7以后改动还是不少
稍微修改了一下这个Fervens A模板 让它能够正确支持自带的thread comment方法
主要参考的是这篇文章
Migrating Plugins and Themes to 2.7/Enhanced Comment Display
关键函数就是那个 wp_list_comments 调用callback函数来显示自定义的comment格式
最简单的用法比如
wp_list_comments('type=comment&callback=mytheme_comment');然后在functions.php里写一下mytheme_comment函数即可