Posts Tagged ‘wordpress’

Migrating WordPress Uploads

Wednesday, November 5th, 2008

我的blog迁移过一次,上次主要是为了更换domain name。今天我又成功地迁移了两个blog,这次主要是为了享受WordPress 一次安装,多处使用 带来的方便。

但我不得不承认,WordPress迁移不是件容易的事。大部分的迁移工作是更该数据库里uploads文件的路径,这些值都是用绝对路径保存在数据库了。必须一一更改这些值(我喜欢export-replace all-import),否则文件位置的变动将导致链接失效。

WordPress用了两个options来设置Upload Path & Upload URL,为什么不基于这两个值用相对位置来管理上传文件?相对位置的好处是:如果移动或改名了uploads文件夹,就只要修改两个options,而不必在posts和postmeta两张表里大动干戈了。

WordPress Commerce

Tuesday, November 4th, 2008

在WordPress基础上建设网店不是不可以,但毕竟blog和e-Commerce各有侧重。要做e-Commerce,自然而然就要求设置产品属性,相关产品链接,库存管理,价格管理,客户管理,销售报告等等。WordPress装个插件,如Instinct Entertainment e-Commerce plugin (WP Shopping Cart) for WordPress,做得相当不错,能完成基本的e-Commerce需求。

但WP Shopping Cart只能是个轻量级的e-Commerce解决方案。它至少无法:

  1. 批处理
  2. 动态过滤产品 (按自定义属性)
  3. 产品套装模型
  4. 复杂价格政策
  5. 客户分组
  6. 自定义报告

在WP Shopping Cart基础上改进一下,让它完成以上功能也不是不可能的。但我认为,如果你有以上需求,选择WP Shopping Cart就是个错误(谨记:WP Shopping Cart只能是个轻量级的e-Commerce解决方案)。

此外,我在考虑:装了WP Shopping Cart plugin,所有的产品页面都是通过一个WordPress页面 (默认叫product-page) 调用,产品页面都是product-page子页面,本身不利于搜索引擎优化。而且,WordPress自身或WordPress SEO Plugins带来的搜索引擎友好的众多特性,产品页面无法享受到。虽然WP Shopping Cart针对SEO做了很多考虑,但WordPress SEO是众人拾柴,WP Shopping Cart SEO features无法与WordPress SEO features匹敌。

其实大部分企业网站并没有购物车需求,只是一个简单得不能再简单的产品或服务展示厅(brochure site or showrooms)。如果WordPress category, tag, cusom field, search应用得恰当,不借助于e-Commerce plugin,也能用WordPress组建一个brochure site。如想要SEO,一个post对应一个产品是最佳方案。设计一个brochure theme就够了。

找来找去,我没找到一个像样的 (适合摆放产品的) brochure theme。

关于WordPress一次安装,多处使用的构想

Sunday, October 19th, 2008

首先,我不能用WordPress Mu版。因为某些plugin 和 theme不支持Mu版。况且,WordPress Mu版相对于WordPress的特有功能是用户自助申请Blog功能,而我所谓“多处使用”,只需要集中管理一个WordPress框架下多个网站,多个网站能同步升级WordPress程序部分,所以,Mu版在此没有优势。

其次,我肯定不是有WordPress一次安装,多处使用需求的第一人。我参照了前人的做法,但觉得它们不够完善。不完善之处主要是前人的想法要求多个网站指向同一个document root,而不同的网站很可能装有其他程序,还会有不同的图片等其他文件。例如,domain1和domain2共用一个WordPress,那WordPress以外的静态页面或静态文件,比如domain1/static-page-or-file-outside-of-wordpress,就会被domain2/ static-page-or-file-outside-of-wordpress访问到。

再次,我的构想适合在独立服务器LAMP环境下实现。以下是具体的实现步骤:

  1. 在一个主控域名上按常规安装WordPress。假设主控域名是domain1,它的document root是/www/domain1。
  2. 假设第二个域名是domain2,它的document root是/www/domain2,WordPress甚至可以安装在子目录/www/domain2/wp。
  3. 除.htaccess和index.php以外,把/www/domain1下WordPress其他文件和文件夹用软连接的方式连接到/www/domain2/wp。多数情况下,不同网站会有不同.htaccess的要求,所以我建议.htaccess还是单独建立为好;domain2的index.php则需要稍作修改(大家看着改吧,应该是很简单的)。
  4. Domain1的wp-config.php则需要为新增的domain2添加一些配置,为不同的域名启动不同的数据库、表、keys等。
  5. Domain2的WordPress安装完成后,进入后台,调整uploads目录的位置,默认是wp-content/uploads,应该改为绝对路径,如/www/domain2/wp/wp-uploads。Full URL path to files (optional)不再是optional,必须作相应修改以便前台能访问到上传的文件。我曾经为隔离domain1和domain2的uploads考虑得死去活来,为了属于domain1 的 static-page-or-file-outside-of-wordpress 不被 domain2/static-page-or-file-outside-of-wordpress访问到,我想过在domain1下建立软连接到domain2的uploads目录,然后用防盗链的方式防止 domain1 和 domain2 对各自 uploads 目录的相互访问。但最后才发现,WordPress uploads folder本来就支持绝对路径(默认值是相对路径),一个复杂的问题就这样轻松解决了。

Godaddy mod_rewrite

Thursday, September 25th, 2008

I have two Godaddy accounts now. One is for a dedicated server, the other is for a deluxe share hosting package. Actually I do not need any share hosting once I get a dedicated server, but someone bought this for me, so I spent some time inspecting how good / bad it is.

I should regard myself as a Godaddy loyal client. I am 100% satisfied with their dedicated server service, and also, Godaddy domain management is the most powerful and convenient I have ever seen. However, Godaddy share hosting is definitely not something workable for me.

I am recently struggling at setting up magento in Godaddy share hosting. Magento setup is 50% successful. I mean, magento can run homepage, wishlist, popular search, etc all right, but it run into blank pages at many points, e.g. about us, customer service, etc. Initially I thought it was mod_rewrite problem, so I used phpinfo to check. I did not find mod_rewrite enabled. I quickly installed wordpress to double check, and if I enable wordpress search engine friendly url features, it runs into 404 error. I searched Godaddy Knowledge Base (FAQ centre). It says:

Mod_rewrite is an Apache web server module installed on all of our Linux servers by default; it does not have to be installed or enabled. Our Linux hosting accounts support most mod_rewrite functionality.

You do not need to enable mod_rewrite in your httpd.conf, as this is handled at a global level. All you need to do is add the desired code to the body of your .htaccess file.

For more information about mod_rewrite see the Apache Module mod_rewrite documentation.

NOTE:The .htaccess file containing the rewrite rules must be in the same directory as the target files.

This article did not help me. So I had to submit a ticket. Within several hours, I got the reply (I am satisfied with Godaddy support reponse speed) but it only contained the same words as the answer from Godaddy Knowledge Base. I googled “godaddy mod_rewrite” after I could not get a clear reply from Godaddy. I should have googled it earlier because soon I found someone mentioned rewrite rules in .htaccess with Godaddy share hosting DO NOT TAKE IMMEDIATE EFFECT.

This solved all my queries. Although I still do not know how Godaddy hide mod_rewrite from phpinfo, after several hours of being installed, wordpress is working properly.

However, magento is still not running properly. I assume it has nothing to do with mod_rewrite settings. By all means, to my opinion, magento is not suitable to run on a share hosting package. Installing magento on Godaddy share hosting account is only for my curiosity. I have been running magento successfully on my dedicated server.

WordPress编辑应该避免使用浏览器的后退

Thursday, March 13th, 2008

我刚才吃了点苦头:我写了两篇贴士,一篇贴士写好发布后,我使用了浏览器的后退按钮,回退到post-new.php页面,这时页面表面上看跟Write Post的页面一模一样,但post_id已经产生,而且跟第一个贴士的id一样,结果第二个贴士保存时,就把第一个贴士给覆盖了。郁闷,只好重新输入。

所以我想提醒大家,尤其是WordPress的编辑,应该避免使用浏览器的后退功能。不过,WordPress也应该更贴心一点,post-new.php应该关闭cache,这样每次进入post-new.php,不论是用浏览器的后退或是点击Write -> Write Post,每次都更新post_id,这样就不会覆盖以前的贴士了。这时的post_id应该是临时的,所以不用担心多次进入post-new.php页面导致数据库保存了空内容的贴士。

我特别喜欢程序在处理完post data以后作一个redirect,这样也可以避免上述数据覆盖的问题,而且解决后退时浏览器提示页面过期、要重新发送数据种种的不友好问题。Header redirect已成我的习惯,这么做好处很大,迄今也没遇到一起redirect after post带负面影响的情景。不过,我发现有同样习惯的人不多。难道有很多不好的scenarios我没想到?

节选设置

Sunday, March 2nd, 2008

大家普遍认为WordPress自带的excerpt功能太弱,于是extend excerpt plugin很多,但我没找到我想要的。这些excerpt plugin大多为了解决html标签截断的问题、字数还是字节的问题、显示格式问题。

我想找的excerpt plugin是为了解决excerpt的缺省值问题,我最喜欢的excerpt值是:

  1. 如果post excerpt不为空,显示该excerpt字段;
  2. 否则,如果post content中含有<!––more––>标签,显示<!––more––>标签之前的内容;
  3. 否则,读取post content的既定字数。

我就这么一个简单的要求,怎么没有现成的excerpt plugin呢?

WP Shopping Cart Not Support utf-8

Sunday, December 30th, 2007

Recommended by WordPress, I installed one of business blogging plugin – WP Shopping Cart. Although I don’t think it’s a good idea to sell anything on this blog, I wanna try the plugin by categorising under WP Shopping Cart my investigation to hundred brands in Bicester Village.

To my disappointment, this plugin (ver 3.6 beta 7) does not support utf-8. I have to leave the plugin there. I don’t wanna do modification to this plugin by myself.

Why Google Analytics Tracking Code Was Not Included In Source Code?

Sunday, December 30th, 2007

这个博客从一开始就装了Google Analytics for WordPress,但我在前台页面的源代码里总看不到tracking code,我为解决这个问题陆陆续续花了不少时间找原因,把plugin反复deactivate and activate,甚至卸载plugin再重装、切换theme,都没见source code 包含任何analytics的字眼。

我在wordpress.org寻求前人的经验,也有人说Google Analytics for WordPress这个plugin无法工作。他最后是放弃了Google Analytics for WordPress,还推荐了另一个google analytics plugin叫sem google analytics。但是我见Google Analytics for WordPress功能远比sem google analytics强大,不舍得放弃。

试装sem google analytics后,我查看了前台页面的源代码,代码里有一行注释,说sem google analytics不追踪admin登录状态。一语惊醒梦中人!同理,我的Google Analytics for WordPress一直就是正常工作着的,只是我一直在admin登录状态去查看源代码,也就无法看到tracking code,但Google Analytics for WordPress一直没给任何提示说明这一点,导致我瞎折腾,这是Google Analytics for WordPress做得不够好的地方。

花了很多时间,总算搞明白一个粗显的道理:Google Analytics for WordPress不追踪admin登录状态

SEO is in the centre of business

Thursday, December 20th, 2007

Blog helps SEO. I have decided to carry out an new ecommerce site using wordpress. From object-oriented point of view, wordpress has nothing to do with product, it would be hard to extend wordpress with ecommerce function. However, SEO is so important part of business. Anything helps SEO, we do it. We cut budget for ad on newspapers, televisions, etc, but we never cut budget on search engines.

Marketing industry may have over appraised the search engines. Maybe it is a good thing for people like me – with some knowledge of SEO, we make it happen. Website is optimised a little bit, at least in the eye of search engines. But the rankings keep changing and keep worrying bosses, so bosses counting on SEO staff, SEO consultants, SEO tools, SEO budget?

Oh, god, lots of money were stolen by our SEO consultancy.

wordpress title不见了

Tuesday, December 11th, 2007

昨天在公司的blog上做搜索引擎优化,做到后来既然把blog homepage的title弄没了,一时没找到原因。

今天在这个自己的blog上只想要添加一个analytics,我用的是google analytics for wordpress plugin 2.0,当我把track帐号输入以后,发现title又一次消失了。title的消失是不是由这个plugin引起的?这有待进一步试验。可现在头痛的问题是:无论我删除了track account,还是deactivate plugin,title还是不回来。难道我错怪google analytics for wordpress plugin?