首页 > Wordpress, 博客相关 > 最近博客折腾笔记(一)

最近博客折腾笔记(一)

在lulu工作的工厂打工的那段时间,我在利用到她们办公室乘凉的琐碎时间的蹭了一段时间的网。蹭网我不自在,写不出什么,所以我利用这些琐碎的时间整了整博客。大概是蛮久没折腾了,心里直痒痒。看到一些新鲜的东西,就尝试着搞搞了。同时解决了博客存在的一些小问题。下面一并记录,供需要的朋友参考。

问题一:我的评论分页翻页出问题了

这个问题是放暑假前,我升级wordpress 2.92到3.0后,一番折腾出现的。每次点日志的评论分页相当于刷新页面,比如http://www.happyla.net/archives/1654.html/comment-page-2#comments会跳转到http://www.happyla.net/archives/1654.html/#comments,得多点几次才能打开,这给我查看之前几页的评论带来很大的麻烦。后来升级wordpress 至3.01后,发现问题还在,我索性移动了整个目录彻底重装了wordpress,发现问题没有解决。我接着尝试用inove原主题替换,发现无济于事。所以我才想到应该是插件问题,我停用了几个插件测试,后来发现停用Permalink Redirect插件后,评论分页正常了。至此问题才得到解决。这个插件我是学阿邙大哥《打造WordPress短地址之YY篇》里的方法设置博客短网址的,现在我只好撤掉了。呵呵。为了解决这个问题,我还特意请求Mucid兄指教,没想到问题出在这个地方,真是得来全不费工夫。

折腾一:增加评论显示评论者浏览器及系统功能

这个功能之前留意过,但当时觉得没有必要,所以一直没有添加。最近心血来潮,想了解下来我博客评论的朋友使用浏览器情况,特意加上。同样问Google,找到了一个Comment Info Detector插件,同时浏览相关资料,开启插件,用进阶方法直接用代码调用。inove主题的使用方法是:在functions.php文件中找到以下语句(大约578行)

| <a href="#comment-<?php comment_ID() ?>"><?php printf('#%1$s', ++$commentcount); ?></a>

后面插入

<?php if (function_exists("CID_init")) { CID_print_comment_flag(); echo ' '; CID_print_comment_browser(); } ?>

。如果你不需要显示国旗,只需要去掉CID_print_comment_flag(); echo ‘ ‘;这段代码。这样搞定了,同时不会调用插件内的css,不会太影响速度。其他主题大部分是在comments.php的相应评论位置插入。

后来我和Mucid聊天时看到他是使用一个名为WP-UserAgent插件。此插件支持的浏览器更多,所以我就考虑换了。同样用网上的方法用代码调用。这里我是参考A.shun博客《WP-UserAgent:评论者信息显示插件》的方法,同comments info detector代码插入方法一样,inove同样是在functions.php的以上位置插入

 <?php useragent_output_custom(); ?>

,具体位置可以自己调整,你可以添加</br>进行换行。具体可以请参考A.shun博客《WP-UserAgent:评论者信息显示插件》一文。

折腾二:首页通过W3C XHTML 1.1验证

这个纯属娱乐。俺看到Mucid把主题写的这么规范,整站通过W3C,心里直痒痒。so也到http://validator.w3.org查看了下自己的博客。不看不知道,一看吓一跳,出现20多个错误,加几个警告。大家知道inove主题是写的很规范的,本身就能通过W3C验证,被俺折腾了些,搞出来很多不规范的代码。虽然不影响网页浏览,但我尝试着修改了一些,直到把首页通过。

当然,W3C标志也让我头疼。比如XHTML 1.1(注意1.0和1.1是不一样的)里target=”_blank”都是不规范的,我查看网上的方法,把target=”_blank”改为rel=”external”。按照网上的方法,同时还要调用一段js代码,代码如下:

function externallinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externallinks;

把这段代码保存为js,然后在header.php中加入

<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/external.js"></script>

调用。这样对应的链接就可以新窗口打开了。

还有我发现的比较纠结的几点:

1.一些Gravatar缓冲插件开启后产生的代码也不规范。

2.大家喜欢把一些js代码、css代码放入footer.php的底部,这样在XHTML 1.1中同样是不规范的。所以我把底部的几个js移到了header里。

3.形如

<script language="javascript" type="text/javascript"> 内容</script>

也是不规范的。只需去掉 language=”javascript” 即可。

4.许多统计代码比如51啦、CNZZ、量子统计在XHTML 1.1中无法通过,这得自己修改了。我的统计代码如下:

CNZZ

<script type="text/javascript" src="http://s4.cnzz.com/stat.php?id=2130362&amp;web_id=2130362"></script>

51啦

 <script  type="text/javascript" src="http://js.users.51.la/3458558.js"></script> 

量子

<script type="text/javascript" src="http://js.tongji.linezing.com/1523670/tongji.js"></script>

W3C验证,本人无法做到整站通过,也只能通过部分页面。同时抱着玩玩的态度。毕竟这也是一种乐趣嘛。感兴趣的朋友可以玩玩。

我比较啰嗦,不知不觉写了一大堆。以上内容仅供参考,如果您发现错误,欢迎指正。因为文章过长,未完待续,另起一文。:)



分类: Wordpress, 博客相关 标签: , , , ,
  1. 2010年8月30日16:32 | #1 Google Chrome 5.0.375.127 Google Chrome 5.0.375.127 Windows XP Windows XP

    我新换的主题很不规范

    [回复]

    朵未 回复: Maxthon 3.0 Maxthon 3.0 Windows XP Windows XP

    呵呵,如果都要按规范现在还比较纠结吧。

    [回复]

  2. 2010年8月30日16:25 | #2 Firefox 3.6.8 Firefox 3.6.8 Windows XP Windows XP

    我没有折腾博客很久了。。。烦心

    [回复]

    朵未 回复: Maxthon 3.0 Maxthon 3.0 Windows XP Windows XP

    呵呵,折腾的自己感觉称心就可以啦。 :smile:

    [回复]

  3. 2010年8月30日12:53 | #3 Internet Explorer 8.0 Internet Explorer 8.0 Windows 7 Windows 7

    只拿别人东西用的飘过….

    [回复]

    朵未 回复: Maxthon 3.0 Maxthon 3.0 Windows XP Windows XP

    我也是拿别人的,自己动手。

    [回复]

  4. 2010年8月29日23:56 | #4 360Safe Explorer 360Safe Explorer Windows XP Windows XP

    呵呵,现在真是没精力折腾。

    [回复]

    朵未 回复: Maxthon 3.0 Maxthon 3.0 Windows XP Windows XP

    呵呵,那就不折腾咯。 :mrgreen:

    [回复]

  5. 2010年8月29日20:07 | #5 Internet Explorer 8.0 (Compatibility Mode) Internet Explorer 8.0 (Compatibility Mode) Windows 7 Windows 7

    WP太复杂,不是我能够搞明白的。决定还是Emlog哈。。

    [回复]

    朵未 回复: Maxthon 3.0 Maxthon 3.0 Windows XP Windows XP

    EM简单些,不过也有折腾余地。 :smile:

    [回复]

  6. 2010年8月29日17:01 | #6 Google Chrome 6.0.472.51 Google Chrome 6.0.472.51 Windows 7 Windows 7

    看来还有(二)下次折腾啥呢

    [回复]

    朵未 回复: Maxthon 3.0 Maxthon 3.0 Windows XP Windows XP

    是啊。得抽个时间补充下,我写这类日志很慢的。

    [回复]

  7. 2010年8月29日15:56 | #7 Internet Explorer 8.0 (Compatibility Mode) Internet Explorer 8.0 (Compatibility Mode) Windows 7 Windows 7

    哇 你们好幸福哇 在一起工作呢 羡慕羡慕

    [回复]

    朵未 回复: Maxthon 3.0 Maxthon 3.0 Windows XP Windows XP

    呵呵,还好哦。今天我回校了。 :smile:

    [回复]

  8. 2010年8月29日14:32 | #8 Firefox 3.6.8 Firefox 3.6.8 Windows XP Windows XP

    怎么我的阅读器里一直看不到你更新?

    [回复]

    朵未 回复: Maxthon 3.0 Maxthon 3.0 Windows XP Windows XP

    额,这篇都看不到更新吗?feedsky的更新的。

    [回复]

  9. 2010年8月29日11:38 | #9 Firefox 3.6.7 Firefox 3.6.7 Windows XP Windows XP

    WP折腾起来很有意思 :mrgreen:

    [回复]

    朵未 回复: Maxthon 3.0 Maxthon 3.0 Windows XP Windows XP

    有时候感觉有意思,但有些时候够郁闷的。 :grin:

    [回复]

  10. 2010年8月29日10:57 | #10 Google Chrome 7.0.503.0 Google Chrome 7.0.503.0 Windows 7 Windows 7

    怎么都w3验证呢 :evil:

    [回复]

    朵未 回复: Maxthon 3.0 Maxthon 3.0 Windows XP Windows XP

    呵呵,临时玩下呗。 :mrgreen:

    [回复]

  11. 2010年8月29日08:19 | #11 Google Chrome 5.0.375.29 Google Chrome 5.0.375.29 GNU/Linux GNU/Linux

    现在commentluv怎么这么恶心?还要注册缩短缓存时间

    [回复]

    朵未 回复: Maxthon 3.0 Maxthon 3.0 Windows XP Windows XP

    这个我倒没注意过,管他类。。。

    [回复]

  12. 2010年8月29日07:17 | #12 Internet Explorer 8.0 Internet Explorer 8.0 Windows XP Windows XP

    不懂程序和代码的路过,没有折腾过博客。

    [回复]

    朵未 回复: Maxthon 3.0 Maxthon 3.0 Windows XP Windows XP

    呵呵,不折腾就多写吧。 :smile:

    [回复]

  13. 2010年8月28日23:19 | #13 Sogou Explorer Sogou Explorer Windows XP Windows XP

    来踩踩~~~

    [回复]

    朵未 回复: Firefox 3.6 Firefox 3.6 Windows XP Windows XP

    欢迎来坐坐。 :smile:

    [回复]

  14. 2010年8月28日16:08 | #14 Firefox 3.6.8 Firefox 3.6.8 Windows XP Windows XP

    小松和joyla也扫除了W3C验证的错误呢.
    1.1的规范更严格了.

    [回复]

    朵未 回复: Firefox 3.6 Firefox 3.6 Windows XP Windows XP

    1.1是严格了些,不过在目前比较纠结。IE浏览器跟不上。IE9应该会支持好了。

    [回复]

  15. 2010年8月27日23:59 | #15 Opera 10.61 Opera 10.61 Windows 7 Windows 7

    啊。你终于回来了哈。

    [回复]

    朵未 回复: Firefox 3.6 Firefox 3.6 Windows XP Windows XP

    有时间就回来坐坐嘛。欢迎来坐坐。 :oops:

    [回复]

  16. 2010年8月27日21:11 | #16 Google Chrome 6.0.496.0 Google Chrome 6.0.496.0 Windows 7 Windows 7

    你用3个统计啊。

    [回复]

    朵未 回复: Firefox 3.6 Firefox 3.6 Windows XP Windows XP

    其实还有一个百度统计。 :grin:

    [回复]

  17. 2010年8月27日19:48 | #17 Internet Explorer 7.0 Internet Explorer 7.0 Windows XP Windows XP

    首页通过W3C XHTML 1.1验证
    _____

    很厉害! :smile:

    [回复]

    朵未 回复: Firefox 3.6 Firefox 3.6 Windows XP Windows XP

    不是很有必要啊,通过首页还是比较容易的,但还是比较纠结。过些日子打算改回原来的。

    [回复]

  18. 2010年8月27日15:55 | #18 Google Chrome 5.0.375.127 Google Chrome 5.0.375.127 Windows XP Windows XP

    生命在于折腾!

    [回复]

    朵未 回复: Firefox 3.6 Firefox 3.6 Windows XP Windows XP

    在必要时候可以折腾一下。

    [回复]

  19. 2010年8月27日13:55 | #19 Internet Explorer 6.0 Internet Explorer 6.0 Windows XP Windows XP

    :!: 我用的ZBLOG没折腾的空间啊!

    [回复]

    朵未 回复: Firefox 3.6 Firefox 3.6 Windows XP Windows XP

    呵呵,还是有的,不过空间比较小。大概更需要技术。 :smile:

    [回复]

  20. pazz7ven
    2010年8月27日12:48 | #20 Google Chrome 6.0.417.0 Google Chrome 6.0.417.0 GNU/Linux GNU/Linux

    我试试能识别不能 :razz:

    [回复]

    朵未 回复: Firefox 3.6 Firefox 3.6 Windows XP Windows XP

    呵呵,这个基本的浏览器、系统都可以识别 :grin:

    [回复]

评论分页
  1. 本文目前尚无任何 trackbacks 和 pingbacks.

订阅评论  Ctrl+Y 启动搜狗云输入法

无觅相关文章插件,快速提升流量