WordPress:FAQ Working with WordPress

来自站长百科
Xxf3325讨论 | 贡献2008年4月29日 (二) 12:04的版本
跳转至: 导航、​ 搜索

返回FAQ

管理

我的文章可以有标题而不是 /index.php?p=76?

参见:

如果我有mod_rewrite我如何找出?

要想得到关于你的服务器的信息,你可以使用PHP Info 功能:

  • 把下边语句粘贴到一个新的记事本 / BBEdit 文件中
<?php phpinfo(); ?>
  • 另存为 info.php
  • 上传到服务器. 在浏览器中访问 (www.example.com/info.php)

浏览器会显示出关于你的php 版本和 mod_rewrite的信息.

info.php文件返回一个列出你的PHP安装详细信息的页面. 你可以查看是否mod_rewrite 被载入. 在apache页眉下面, 查看Loaded Modules 部分,可以看到是否mod_rewiite 列出.

我如何改变文件和文件夹许可?

参见:

为什么版本号不是按照任何特定的周期序列?

WordPress更新版本的版本号WordPress 可能不是按照某个严格的不变的或者是周期数字排列(或者是测试版的按字母顺序排列), 因为版本号反应出了相关程序, 现有或者前版本的改变。这样,如,因为版本1.2主要是修正版本1.0 (大约是60% 的代码经过改动), 1.1 就被 ’跳过’了。


我如何打开Permalinks, 我该如何处理错误?

参见:

用户等级有什么用不同的等级有什么权限?

参见:

wp-config.php644权限会危及在我的共享服务器上的其他用户的用户名和密码吗?

这是一个PHP 在你的服务器上安装时的局限. 如果你以前使用了MovableType, 带有suexec 的Perl 可能已经安装,这样 Movable Type 作为你的使用者来执行. 在这种情况下, PHP 作为服务器用户运行。这就是为什么必须至少是 444. 有一个phpsuexec但是似乎很多主机都不使用它.

尽管如此,这通常在现代共享主机上不是什么问题,因为文件是随便阅读的,但是每个帐户建立时带有“jailshell" ,保证人们被锁在自己的目录中, PHP 还可以轻易的使用 open_basedir进行约束,保证人们不能改写PHP脚本来阅读你的文件. 如果你实在需要,你可以联系主机,看看可以采取什么措施。


用户登陆后我如何重定向用户回到我的blog主页?

安装插件,From where you came, 如果你的用户从主页点击了Log in 链接,他们就会在登陆后被直接返回。

我如何为我的文件改变权限,这样我可以使用模板编辑器编辑它们?

参见:

我如何防止我的图片被别的站点做成热链接?

你可以使用你的.htaccess文件来保护图片不被热链接, 或者, 换句话说, 被别的网站链接到了. 这可能会影响你的带宽,因为如果某人直接链接到你的站点上的图片,你就失去了这部分带宽。

Clockwatchers的htaccess 图片指导 给出了更多详细内容.

你可以使用这个工具来查看是否图片被适当的保护,这也有几个额外的小提示。

要想得到对付热链接的更好的办法请查看A List Apart's Smarter Image Hotlinking Prevention.

我如何使用phpMyadmin备份和恢复我的WordPress数据库?

参见:

我如何阻止灌水?

灌水是当很多的回帖(可能是垃圾信息)在很短的一个持续时间段在你的站点上同时出现。 Mark Ghosh's的文章, 阻止灌水-一个非常简单的解决方法, 以及相关的组织灌水hack, 允许你设置一个每两个贴之间的时间间隔,可以防止回帖太快。

代码修改的一个附件如下 (适用WP 1.2) :

在wp-comments-post.php (在回帖中间,你应该找到合适的地方), 加入如下代码:

// Simple flood-protection
$lasttime = $wpdb->get_var("SELECT comment_date FROM $tablecomments ORDER BY comment_date DESC LIMIT 1″);
if (!empty($lasttime)) {
$time_lastcomment= mysql2date(’U', $lasttime);
$time_newcomment= mysql2date(’U', $now);
if (($time_newcomment - $time_lastcomment) < 300)
die( __(’Sorry, this blog only allows a new comment once every 300 seconds. If you really want to write a comment,
just wait a few and hit refresh on this page. Chances are you tried to add a comment about halfway between 0 and 300 seconds.   
Comment flooders are annoying. Thank you for being patient.’) );
}

为什么我不能删除未分类的分类?

任何Administration > Manage > Categories# of Posts 值不为零的分类不能 被删除. 未分类的 分类必然指向某个文章,但是所有 页面 指向这个未分类的 分类.这样尽管可能没有文章指向这个未分类的 分类,页面还是包含在 # of Posts的记录当中。

默认的分类不能被删除,即使它是空的,尽管如此你可以在管理面板中的Options - Writing为你的帖子或者链接指定你的默认分类。

为什么写或者编辑页面时没有页面模板操作?

如果写或者编辑页面时没有页面模板操作,可能是因为没有 带有合适结构的模板文件。 为了让页面模板框可用来分配 页面,你的主题中必须至少有一个模板文件,在模板文件开头的地方拥有如下代码:

<?php
/*
Template Name: Links
*/
?>

这个例子来自WordPress 默认主题wp-content/themes/default/links.php file.

参见:

页面模板

配置

我如何才能改变日期/ 或者时间如何显示?

参见:

我如何控制别人的评论?

参见:

Discussion Options 意味着什么?

参见:

我如何安装插件?

参见:

当我建立不止一个分类的时候,我如何才能更改分类之间的外观?

要想设定分类的显示, 打开index.php文件然后找到 <div class meta>. 你会看到如下代码:

<?php the_category() ?>

圆括号( ) 和引号之内, 添加或者更改来得到你想要的新界面.

如果你想让分类中间是逗号,标签如下:

<?php the_category(',') ?>

如果你想要箭头,标签如下:

<?php the_category(' > ') ?>

如果你想要分隔符,标签如下:

<?php the_category(' &bull; ') ?>

如果你想要"竖线", ( | ) 标签如下:

<?php the_category(' | ') ?>

运用你的想象力和创造力,让分类之间的分隔以你喜欢的方式呈现出来。

为什么所有的评论必须审核?

找到Options > Discussion面板确定An administrator must approve the comment (regardless of any matches below) 是未选中状态. 如果选中这个选项, 所有的评论会被发送到队列中以等待审核。确认Hold a comment in the queue if it contains more than x links 是非空的,包含一个大于零的数字。如果这个值是空白或者零,所有的评论包含的链接都会被调整。如果上面提到的操作都是未选中的,链接调整值大于零,你还会碰到问题, 你的 垃圾信息词语 列表信息中可能会有空行,标点或者单一的字母。在列表项目之间必须有空格或者每个项目必须在它自己的那一行中。如果你完成这些后,然后更新一下你安装的评论垃圾信息插件。如果问题仍然存在,一个一个的禁用评论垃圾信息插件来确定问题出在哪里,联系插件作者寻求帮助。

如何阻止别人发布HTML 评论?

是否允许评论区域的HTML 标签由kses.php文件管理,该文件在wp-includes 文件夹中。

使用文本编辑器打开这个文件, 把HTML 标签列表定位在文件顶部。每个HTML 标签都列在一个单独的行,在允许的标签中的一个PHP数组结构中。以// 开头的行都是commented-out, 或者是禁用的。所以以//开始的指定的HTML标签都是 允许出现在评论中的。

要想阻止人们在评论中添加HTML, 编辑你的 kses.php 文件,按照你想要的,允许或者不允许特定的HTML标签出现在评论中,可以通过添加//到列表的适当的行的最前面实现。 要想阻止所有的HTML标签, 就注释掉所有允许HTML标签的行. 确认完成后保存文件。

注意如果你可以删除这些行的话,最好还是用注释掉来代替删除, 通过在每行开始的地方添加//来达到相同的结果,这样可以确保将来可能想重新激活这些标签。

How do I disable comments?

First, unchecked Allow people to post comments on the article on the Options > Discussion panel. This will only disabled comments on future posts. Now, to completely disable comments, you will have to edit each past post and uncheck Allow Comments from the Write Post SubPanel. Alternatively, you could run this MySQL query from the command line on a shell account or using WordPress:phpMyAdmin: UPDATE wp_posts SET comment_status="closed";

If your goal is to permanently disable comments, then you should delete the wp-comments-post.php file as well.

我如何禁用注释?

首先,First, unchecked Allow people to post comments on the article on the Options > Discussion panel. This will only disabled comments on future posts. Now, to completely disable comments, you will have to edit each past post and uncheck Allow Comments from the Write Post SubPanel. Alternatively, you could run this MySQL query from the command line on a shell account or using WordPress:phpMyAdmin: UPDATE wp_posts SET comment_status="closed";

If your goal is to permanently disable comments, then you should delete the wp-comments-post.php file as well.


我该如何禁用trackbacks 和pingbacks?

首先在 Options > Discussion 面板中,取消选中Allow link notifications from other Weblogs (pingbacks and trackbacks.). 这只是在将来的文章中禁用了trackbacks 和 pingbacks 。现在,完全禁用trackbacks 和 pingbacks,你将不得不编辑每个过去的文章并且从Write Post子面板取消选中Allow Pings 作为选择,在一个外壳账号上从命令行运行 MySQL 查询或者使用PHPMyAdmin: UPDATE wp_posts SET ping_status="closed";

如果你的目标是永远禁用trackbacks 和pingbacks, 那么你还应该删除 wp-trackback.php 文件。

How do I disable my RSS or syndicated feeds?

To disable your RSS or syndicated feeds, you must delete the wp-atom.php, wp-commentsrss2.php, wp-feed.php, wp-rdf.php, wp-rss.php, and wp-rss2.php files.

我如何禁用 RSS 或者是 syndicated feeds?

想禁用RSS 或 syndicated feeds, 你必须删除wp-atom.php, wp-commentsrss2.php, wp-feed.php, wp-rdf.php, wp-rss.php, 和 wp-rss2.php文件。

How do I change the site admin name?

To change your Admin Name, in the Administration Panel, choose the Users->Your Profile tab. Make your changes there. However, you are not able to change the username from within the Administration panel. In order to do this you must directly edit the MySQL database, however this is not recommended as your username is not often seen by other users.

See:

我如何更改 站点管理 的名字?

要想改变你的管理名字,在Administration Panel中,选择 Users->Your Profile 标签. 在这里进行更改。尽管如此,你不能在管理面板中更改用户名 。为了更改名字你必须直接编辑 MySQL 数据库。尽管如此,建议不要该你的用户名,因为别人并不能经常看见你的名字。

参见:

How do I find the absolute path I need for uploading images?

To find the absolute path of a page, absolutepath.zip will help you. Download, unzip, ftp to the location of the page / image / directory and then call the file in your browser - http://www.example.com/images/absolutepath.php

我如何找到所需的绝对路径上传图片?

为了找到一个页面的绝对路径,absolutepath.zip 可以帮助你。下载,解压缩,上传到page / image / directory 的位置,然后在浏览器中浏览文件 - http://www.example.com/images/absolutepath.php

Which files do I change to alter the way my blog looks?

The following files affect the public display of your site, and each can be easily changed by using the Built-in Editor from the Templates option in your admin screen:

   * index.php
     This affects the layout of your content.
   * style.css
     This is how the style and presentation of your blog is controlled.
   * wp-comments.php
     This controls the layout of user-submitted comments and trackbacks, 
     and the comments submission form.
   * wp-comments-popup.php
     Only needed if you decide to use a popup comments box.
     (Popup comments are off by default).

我可以改变哪个文件来替换我的blog外观?

以下几个文件影响你的站点的外观, 通过管理界面的Templates操作里的内建编辑器,每一个都可以很容易的做出改动:

   * index.php
     影响内容的版面.
   * style.css
     控制你的blog的样式和界面.
   * wp-comments.php
     这个控制用户提交注释和trackbacks,还有评论提交的版面 .
   * wp-comments-popup.php
     只有当你决定使用 popup comments box.的时候才需要
     (Popup comments 默认时是关闭的).

Can I have popup comments?

To enable popup comments, choose the appropriate method for the version of WordPress you are using.

我能拥有popup comments吗?

想要激活popup comments, 根据你使用的WordPress版本选择合适的方法.

WordPress version 2.0 Default Theme

WordPress 2.0版本默认主题

Inside header.php add this line:

<?php comments_popup_script(); ?> 

above this line:

<?php wp_head(); ?>

header.php 内加入该行:

<?php comments_popup_script(); ?>

添加在下面这行之上:

<?php wp_head(); ?>

For example:

<?php comments_popup_script(); ?>
<?php wp_head(); ?>
</head>

例如:

<?php comments_popup_script(); ?>
<?php wp_head(); ?>
</head>

WordPress 2.0 Classic Theme

In the file header.php locate this line (line 21):

<?php //comments_popup_script(); // off by default ?>

And remove the first comment markers, changing it to this:

<?php comments_popup_script(); // off by default ?>

WordPress 2.0 经典主题

在文件header.php中找到这行 (第21行):

<?php //comments_popup_script(); // off by default ?>

然后删除第一个注释标记,更改为:

<?php comments_popup_script(); // off by default ?>

WordPress version 1.5 Default Theme

Inside header.php add this line:

<?php comments_popup_script(); // off by default ?>

below this line:

<?php wp_get_archives('type=monthly&format=link'); ?>

Example:

<?php wp_get_archives('type=monthly&format=link'); ?>
<?php comments_popup_script(); // off by default ?>
<?php wp_head(); ?>

WordPress 1.5版本默认主题

header.php 添加 该行:

<?php comments_popup_script(); // off by default ?>

在下面这行代码之下:

<?php wp_get_archives('type=monthly&format=link'); ?>

例如:

<?php wp_get_archives('type=monthly&format=link'); ?>
<?php comments_popup_script(); // off by default ?>
<?php wp_head(); ?>

WordPress version 1.5 Classic Theme

Inside header.php is this line:

<?php //comments_popup_script(); // off by default ?>

Change that to

<?php comments_popup_script(); // off by default ?>

WordPress version 1.2

Inside index.php is this line:

<?php //comments_popup_script(); // off by default ?>

Change that to

<?php comments_popup_script(); // off by default ?>

WordPress 1.5 版本经典主题

header.php内有如下这行代码:

<?php //comments_popup_script(); // off by default ?>

更改为

<?php comments_popup_script(); // off by default ?>

WordPress 1.2版本

index.php 内有如下这行代码:

<?php //comments_popup_script(); // off by default ?>

更改为

<?php comments_popup_script(); // off by default ?>

How do I upload images?

To permit images to be uploaded to your site:

From the admin panel, go to Options -> Miscellaneous

  • Select the option to Allow File Uploads
    • If you need help with finding the absolute path, see [[WordPress:#How_do_I_find_the_absolute_path_I_need_for_uploading_images.3F|How do I find the absolute path I need for uploading images?]].
    • If you need help with changing permissions, visit WordPress:Changing_File_Permissions.
  • Then check main menu across the top. Click Upload
  • In Wordpress 2.0, go to Write -> Write Post or Write -> Write Page and use the upload interface therein.

我如何上传图片?

要想允许上传图片到你的站点:

从管理面板中找到Options -> Miscellaneous

  • 选择Allow File Uploads
    • 如果你需要找到绝对路径的帮助信息,参见 [[WordPress:#How_do_I_find_the_absolute_path_I_need_for_uploading_images.3F|我如何找到所需的绝对路径上传图片?]].
    • 如果你需要更改许可的帮助信息,参见 更改文件许可.
  • 然后查看顶部的主目录,点击Upload
  • Wordpress 2.0中,找到Write -> Write Post 或者 Write -> Write Page 然后使用其中的上传界面。

Can I change where the WordPress Database Plugin saves the backups?

Currently (as of WordPress 2.0) the WordPress Database Plugin saves the backups in the folder wp-content/backup-xxxxxx (where xxxxxx is a randomly generated sequence). To change the folder used, change the wp-db-backup.php file.

In Version 1.7 of the WordPress Database Plugin you would change line 22 of wp-db-backup.php where it says

define('WP_BACKUP_DIR', 'wp-content/backup-' . $rand);

to something like:

define('WP_BACKUP_DIR', 'mydir/mysubdir');

我可以改变WordPress Database Plugin 把备份保存在哪吗?

通常(到WordPress 2.0为止) WordPress Database Plugin 把备份保存在文件夹 wp-content/backup-xxxxxx (xxxxxx 是一个随机生成的序列号). 想改变使用的文件夹,改变wp-db-backup.php 文件就可以了.

在WordPress Database Plugin版本1.7,你可以改变第22行的 wp-db-backup.php ,内容如下

define('WP_BACKUP_DIR', 'wp-content/backup-' . $rand);

把上边的语句改成这样:

define('WP_BACKUP_DIR', 'mydir/mysubdir');

Modifying

Can I change the Smilies?

See:

修改

我可以改变Smilies吗?

参见:

How do I edit files?

See:

我如何编辑文件?

参见:

What is The Loop?

See:

什么是 Loop?

参见:

How can I change the URL-structure for my posts?

See:

我如何改变我的文章中的URL结构?

参见:

How can I change URL-structure for my posts on a Windows server?

See:

我如何改变Windows 服务器上的文章中的URL结构?

参见:

How do I use WordPress Template Tags to change what is displayed on the blog?

See:

我如何使用WordPress 模板标签来更改blog上显示的内容?

参见:

How do I get All links to open in a new window?

Put this inside the <head> section of your Theme's template header.php file:

<base target="_blank" />

See:

我如何让所有 链接都在新窗口中打开?

把下边的语句放到你的主题的template header.php文件的<head>部分:

<base target="_blank" />

参见:

How can I add an image to my RSS feed?

See:

我如何添加图片到我的RSS feed?

参见:

How can I stop my own comments being mailed to me?

WordPress version 1.2 This will stop WP from sending you a mail if the email address you used when you posted the comment was the same as the email address for the author of the post (which is the address the notification email gets sent to). This applies to v1.2 / 1.2.1 code ONLY.

In functions.php change the following line:

if ( == $user->user_email) return false; // If there's no email to send the comment to

to

if ( == $user->user_email || $comment->comment_author_email == $user->user_email) return false; // If there's no email to send the comment to

我如何阻止我自己的评论被邮寄给我?

WordPress 1.2版本 如果你发表回帖时使用的邮件地址和这个文章的作者邮件地址相同的话将会阻止WP给你发送邮件 (通知邮件发送的地址). 这只能用于版本1.2 / 1.2.1 。

在functions.php文件中更改如下代码:

if ( == $user->user_email) return false; // If there's no email to send the comment to

to

if ( == $user->user_email || $comment->comment_author_email == $user->user_email) return false; // If there's no email to send the comment to

If I turn off comments, it says "Comments Off" on the weblog. so how do I change that?

To turn your comments feature off:

WordPress version 1.2

Line 58 of wp-includes/template-functions-comment.php has the words 'Comments Off'

WordPress version 1.3

Line 98 of wp-includes/template-functions-comment.php has the words 'Comments Off'

如果我关闭评论,blog上显示"Comments Off" ,如何才能更改成这样?

要想把评论功能关闭:

WordPress 1.2版本

wp-includes/template-functions-comment.php 文件的第58行有'Comments Off'

WordPress 1.3版本

wp-includes/template-functions-comment.php文件的98行有'Comments Off'

How do I change what is shown when I password protect a post?

To create password protected text, see Line 19 of wp-includes/template-functions-post.php for that information.

当我使用密码保护某文章时,我如何改变显示内容呢?

要创建密码保护文本, 查看wp-includes/template-functions-post.php 文件的19行可以找到更多信息。

How can I allow certain HTML tags in my comments?

WordPress versions prior to 1.2

If you would like to override the $allowedtags variable in kses.php you may do so in your my-hacks.php file, provided you add the following code after you set up the $allowedtags array.

define('CUSTOM_TAGS', true);

我如何在评论中允许特定的HTML标签?

'WordPress 1.2及以前版本

如果你想不考虑kses.php 文件中$allowedtags 的数量,你可以在my-hacks.php文件中达到目的, 建立$allowedtags数组之后,添加如下代码.

define('CUSTOM_TAGS', true);

How can I add advanced search ability to WordPress?

See:

我如果添加高级搜索功能到WordPress?

参见:

Posts

Posts

How do I upload an image and display it in a post?

To permit images to be uploaded to your site:

  • Then check main menu across the top. Click Upload

我如何上传图片并让它在某个文章中显示?

要想允许上传文件到你的站点:

  • 然后检查顶部的主目录,点击 Upload

Refer to the following articles to align the image in the post:

See:

查阅如下文章,在你的文章中排列图片::

参见:

What is pingback?

See:

什么是pingback?

参见:

What is trackback?

See:

什么是trackback?

参见:

Where is the permalink to my post?

See:

我的文章的permalink 在哪?

参见:

Can I use desktop blogging software?

See

我可以使用桌面blogging 软件吗?

参见:

Can I blog by email?

See

我可以用邮件写blog吗?

参见

Spam, Spammers, Comments

What can I do to stop comment spam?

See:

More Information on Comment Spam

See:

What Spam words do I need?

See:

垃圾信息, 发送垃圾信息的人, 评论

如何才能阻止评论垃圾信息?

参见:

有关评论垃圾信息的更多信息

参见:

我需要什么样的垃圾信息词汇?

参见:

Why are all the comments being moderated?

If you are getting all comments sent to moderation when they should not, it's probably your spam words list in Administration Panel->Options -> Discussion. It probably has either a single character, OR a blank line OR extra whitespace. Take those out.

Right click in the Spam Words box, Select All then Copy and paste it into Notepad to check it.

With spam plugins adding to that list, it's not easy to check for odd data, and it's easy to miss multiple blank lines. This way makes it easier.

Check it carefully :)

为什么所有的评论必须要审核?

如果你把所有的评论都发送审核,而实际上并不需要的话,很可能你Administration Panel->Options -> Discussion中的垃圾信息词汇 列表只有一个字或者一个空行或者几个空格,把他们删除。

右键单击Spam Words 框,选择所有,复制并粘贴到记事本来查看.

添加垃圾信息插件到列表中后, 查看临时数据变的不那么简单了,而且很容易忽略多个空行。 这样会让审核变的容易些。

仔细检查 :)

Importing and Exporting

How do I Import a WordPress WXR file when it says it is too large to import?

If a WordPress WXR file, an xml file exported from WordPress, is too large to import, there are several things you might try to overcome that limit.

  • Break the WordPress WXR file into smaller pieces by separating the data between a post and pasting the header into each file.
  • Increase the PHP memory limit in php.ini by changing the memory_limit setting (e.g. memory_limit = 64M ;) Note: many hosts don't allow this.
  • Increase the PHP memory limit via .htaccess (e.g. php_value memory_limit 64M). Note: many hosts don't allow this.
  • Increase the PHP memory limit via wp-config.php (e.g. define('WP_MEMORY_LIMIT', '64MB');)

See:

导入和导出

当提示我说文件太大而无法导入的时候,我如何导入WordPress WXR 文件?

如果从WordPress 导出的WordPress WXR 文件, xml文件, 太大而无法导入, 有几种方法你可以尝试下以克服这个限制.

  • 通过在一个文章中把数据分开成几个小文件,把头部信息放导每个文件中,这样把 WordPress WXR 文件拆分成几个小的部分.
  • 在php.ini文件中,通过更改内存限制设置把PHP 内存限制提高, (e.g. memory_limit = 64M ;) 注意: 很多主机不允许这样.
  • 通过 .htaccess文件提高PHP内存限制 (e.g. php_value memory_limit 64M). 注意: 很多主机不允许这样.
  • 通过 wp-config.php文件提高PHP内存限制(e.g. define('WP_MEMORY_LIMIT', '64MB');)

参见:

Back to FAQ 返回FAQ