WP标签和分类的数据结构和使用特点

WordPress建立了一个词语(term)表,在此基础上,建立词语分类系统表(term_taxonomy),建立不同分类法各自可用的词语表。其数据关系如图所示(根据wp 2.9)。

WP词语表及标签分类的数据模式

可以看到三种分类系统:标签(post_tag)、分类(category)、链接分类(link_category),这三种标识可以理解为“词语”的不同用途。

根据数据结构,和少量试验,留意到以下几点:

1)post中,每个独立发出的对象都有一个记录,例如每个文章版本和上传的媒体文档,wp可以为其单独关联标签或分类,即,每个版本使用的标签不同,都有记录,上传媒体文档也可以关联标签和分类,但此功能目前还未包含在wp 2.9中。

2)标签、分类等不同分类法使用同一个“词汇表”,词汇的“别名”(slug,注意,不是name)是唯一的。所以当试图在tag或category中分别添加同名词汇(已别名为准),系统会对应到已有词汇表,并拒绝添加slug重复的词汇(但并没有任何提示)。
例如:
已有标签别名“abc”,此时在分类中添加一个别名为“abc”的分类,系统不会重复添加词汇表,而是设定为将同一词汇“abc”作为标签使用。反之亦然。

初步体会:

1)在创建标签、分类、链接分类时,保持名称和别名(name, slug)一致。虽然系统允许你改成不一致,但那样容易给应用管理带来困惑。

2)虽然分类、标签等是分别使用的,但对意义相同的词语保持一致,这样语义明确,将来想修改时,可以仅在一处一次性修改,很方便。

3)对于内容少的个人日志而言,分类和标签也许用好一套就可以了。但对于有较多内容,需要提供全部内容的良好索引机制而言,分类系统和标签系统各自有不同的用途,互相配合使用,需要自己有一个清晰的规划。笼统地说,标签是面向发布对象的,分类则是预设的,一般而言,分类宜简明恒定、标签比较随意。

升级WordPress 2.8.6 到 2.9

网站刚建,正在配置优化,看到最新版的2.9,是一个较重要的版本升级,于是决定先升级再配置、优化。在后台自动升级,不成功,出现以下错误提示:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2764934 bytes) in /home5/ninoneum/public_html/ee-forum.org/wp/wp-includes/http.php on line 1331

搜索结果很多,就不引用了,得知这是php或wp设置参数问题,建议无非三条:

  1. 修改php.ini                            memory_limit = xxM
  2. 在程序里面添加                     ini_set(‘memory_limit’, ‘xxM’);
    对wp,wp-settings.php 中有设定(在某个版本开始我没求证)
  3. 在根目录.htaccess 添加     php_value memory_limit xxM

具体数值应该比现有限制加一倍,例如 32M(33554432) -> 64M

据说修改了php.ini,可能要重启服务器。后面的方法,则可能受到服务器设置的限制,不一定生效。我使用的是Bluehost服务器,但我无法修改php.ini,想着没事最好不要去找服务商,于是找到 wp-settings.php 先试试运气。一找就找到了:

if ( !defined(‘WP_MEMORY_LIMIT’) )
define(‘WP_MEMORY_LIMIT’, ’32M’);

if ( function_exists(‘memory_get_usage’) && ( (int) @ini_get(‘memory_limit’) < abs(intval(WP_MEMORY_LIMIT)) ) )
@ini_set(‘memory_limit’, WP_MEMORY_LIMIT);

将上面的数字32M改为64,再回到后台执行升级,OK

今天股票也涨了,运气不错滴说;-)

—-

顺便保留一个帖子,作为备忘。这里解释了在Bluehost上修改php.ini无需重启的特点,和一些操作的注意事项。

Bluehost Clarification

Maximus284 – December 18, 2008 – 09:17

I am one of the tech support staff for the bluehost companies and i would like to clarify a few settings on our system.

Your PHP.INI file is the file you need to modify in order to increase your memory limit.

the settings you will need to modify are these:

max_execution_time = 30 ; Maximum execution time of each script, in seconds (set this to something high like 300)

max_input_time = 60 ; Maximum amount of time each script may spend parsing request data (set this to something high like 600)

memory_limit = 10M ; Maximum amount of memory a script may consume (set this to something like 500M)

Then in the php config icon of your account, set your site to the php5 (single php.ini) settings as the Fast CGI is not compatible with some drupal installations. if you find that fast cgi works, great if not, just stay on the php 5 setting.

Also, you do Not need to , and you cannot reboot the server on bluehost. We have a special modification to our server that allows the php.ini files to be initialized on the fly and it does not need to be restarted every time a change is made. Therefore, make the changes in the php.ini and refresh your site a couple of times and the new settings will be applied.

To see if the settings you are making in your account are taking affect, put a phpinfo.php file in your account and use the <? phpinfo(); ?>

Lastly, do not use the php_flag variable in our server. The .htaccess file does not recognize that flag and it will result in your account producing a 500 error, just make your modifications to the php.ini file itself.

If the above memory fix does not solve your problem, there may be a file in the drupal that is limiting your memory usage. (as this line suggests here: “ini_set(‘memory_limit’, ’12M’); in your sites/default/settings.php file”)

If all the above doesn’t work, contact the bluehost support and drupal to see if there are any other fixes to your problem and/or any other files you may need to modify.

Thanks

—-

用户author和Permalink设置上发生的小问题

测试中创建了一个用户名为“author”,以此用户添加的文章使用固定链接permalink访问时总是404——找不到。

经过一番折腾,发现问题可能是固定链接设置里的 %author%,把这个换成别的,或吧author创建的文章作者改成别的用户,上述错误就不出现了。

这是个很小,很特别的问题。

上传文件路径移到wp安装目录之外的问题

目的

将上传路径由wp安装目录中转移到其他位置。

问题

相关设置在杂项“默认上传路径”(默认为 wp-content/uploads)和“文件的完整URL地址”(默认为空白)。前者为相对地址,相对于当前wp安装目录。改成绝对地址(形如 /pub/files),在我的虚拟服务器上,就直接定位到真正的根目录了,所以上传会报告“无法创建。。。是否有权限之类的”。网上有不少都说是要修改权限,有些人遇到的也许是权限问题,但对虚拟主机用户,可能主要是这里的“绝对路径跑出界”的问题,(为此我也折腾了一番,授所有的权都没有用,才想到这个)。

方案

将默认上传路径改为虚拟主机服务器上的绝对地址,形如:

/…/…/MyDomainName/pub/files (…/… 部分是什么,视乎你的主机)

同时,将“文件的完整URL地址”设为:

http:// MyDomainName/pub/files

* 这两者的设置必须是一致的,否则会出问题,造成404文档找不到的错误。

其它问题

  • 没有普通文件上传。全部被归为“媒体”,上传有些文件类型如xml,log,则报告不符合安全规则之类。
  • 文章中“添加媒体”默认的位置为“相册”。在控制板上叫做“媒体库”。

修改安装目录遇到的问题

目的:把WordPress安装到根目录下的子目录wp中,内容(默认在 wp的 wp-content 子目录),包括permalink或将来静态化目标、上传的文档的目录,则改在安装目录之外,在网站根目录下创建。例如:

  • 安装目录为:\wp
  • 发布目录为: \pub
  • 上传文档目录为:\pub\files

过程

按主机管理员提示,在wp下执行 install.php ,报告正常,出现 adim 登陆页面。登陆正常。然后,修改博客地址,修改前:

  • WordPress安装地址(URL):  http://<mydomain>/wp
  • 博客地址(URL):http://<mydomain>/wp

改为

有提示:“如果您想让博客地址和 WordPress 的安装地址 不相同 的话,请在这里输入您期望的地址。” 按照其中提示的步骤,复制 index.php到根目录,并修改

require(‘./wp/wp-blog-header.php’);    改为   require(‘./wp-blog-header.php’);

在此之前,设了自定义固定链接:

  • /pub/%year%/%monthnum%/p%post_id%.html

上述操作完成(根目录.htaccess 自动创建),复制修改好的index.php到根目录,操作完毕。

问题:无法从根目录 index.php 进入

执行 index.php,出错,无法进入wp。改回原来状态,恢复正常。

问题分析与解决

根目录下有一个index.html,执行index.php,总是被转向读出该文件。估计与访问根目录的默认文档设置顺序有关(未查证)。将index.html删除,就正常了。