个人工具
名字空间
变换
操作

WordPress:I Make Changes and Nothing Happens

来自站长百科
跳转到: 导航, 搜索

Things are going great. You have figured out how to write a post, how to make a few categories, and maybe even add a plugin or two. Then it happens. You make a few changes in your WordPress Theme and when you view your WordPress site, nothing has changed. Your fix isn't fixed. Your change isn't changed. NOTHING HAS CHANGED! You want to scream, pull out your hair, pound on your computer, and shout blame.

事情进展得非常顺利。你已经领会到了怎样写一篇文章, 怎样制作一些目录, 甚至怎样 添加一个插件 或者两个。然后突然,你对你的WordPress主题做了一些更改,但是当你访问你的WordPress站点的时候,什么也没有变。你的解决方法没有解决问题。你做的更改没有改变什么。什么也没有变!你想要尖声喊叫,拽住你的头发,重击你的电脑,并且大声地喊骂。

Hang on. Calm down. A great many errors are in fact mistakes born of haste. Even if you're operating under a tight deadline, try to remain calm, and collected, as you proceed. It will help. If you start to get unduly tense, or frustrated, simply get up and walk away for a few minutes. Sometimes all it takes is a fresh, rested pair of eyes to spot a missing semi-colon, or an extra quote mark, or to realize that the solution is much simpler than you originally thought.

停住。冷静下来。许多错误事实上是因为匆忙而导致的过失。即使你在一个非常紧急的时间内操作,在你进行操作时,也要试着保持冷静,和镇静。这样做对你是有益的。如果你过度紧张,或者心灰意冷,就站起来,走几分钟。有时候所需要的就是一双炯炯有神的双眼来发现一个丢失的分号,或者一个引号,或者要明白解决办法比你原先所想的要简单的多。

The problem might be with WordPress, it might be with your database, it might be with your server, or it might be something you did to screw things up, but the reality is that a lot of the time it is none of those things. The culprit is probably your Internet browser.

问题可能在于WordPress,在于你的数据库,在于你的服务器,或者是因为一些你想使情形转好而做的事,但事实是,大多数情况下,都不是因为这些事情。罪魁祸首可能是你的网络浏览器。

Whatever the problem is, we're here to help. Let's look at the possible problems and solutions for what to do when you make a change and nothing happens.

不管问题是什么,我们来这儿是寻求帮助的。当你做出了更改,但是什么也没发生时,让我们来看看可能存在的问题和可能的解决办法。

目录

The Browser Cache

浏览器高速缓冲存储

Did you know that a computer is supposed to make your life easier? Less complicated? It is supposed to save you time and energy and actually improve your life. No? Well, maybe not, but your Internet browser does its best to try to make your life a little easier. 你知道一个电脑可以使你的生活变得更加地轻松?更加地简单?它可以给你节省时间和精力并且真正地提供了你的生活质量。不是?哦,有可能不是的,但是你的网络浏览器尽力使你的生活变得简单一点。

When you first visit a web page, it often takes a while to load, right? But the next page you visit within that site doesn't take so long to load. This is because, in an effort to be helpful, the browser stores the information on your computer so it reloads it from your computer, not from the actual site. This is called the cache and it is meant to speed up your Internet browsing. 当你第一次访问一个网页的时候,通常需要一些时间载入,对吗?但是你访问那个站点的下一个网页时,就不需要这么长的时间载入。这是因为,为了起作用,浏览器在你的电脑上储存了信息,这样它重新从你的电脑上载入网页,而不是从那个站点上。这个叫做告诉缓冲存储而且这意味着可以提供你的因特网浏览的速度。

The term cache may sound familiar. Remember the pirates and thieves of old who would stockpile their treasures in a cave, hole in the ground, or somewhere "safe". Called thecache, the Internet browser stores files and information for the browser to reuse when the page is refreshed or viewed again. 术语隐藏也许听起来非常地熟悉。记得旧时的海盗和小偷会将他们的宝藏藏在一个洞穴中,地洞中,或者其它"安全"的地方。叫做隐藏,因特网浏览器储存文件和信息,当网页刷新,或者需要再次访问的时候,浏览器便可以再次使用储存的信息和文件。

The problem comes when you make a small change to your site and the browser doesn't recognize it as a significant change, so it reloads the same page you just looked at. The solution is to clear or empty your browser's cache.

问题在于,当你在站点上做一些较少的更改的时候,浏览器不认为它是一个重要的改变,因此它重新载入了你正在看的网页。解决办法是清除或者清空你的浏览器的高速缓冲存储

Clearing the Browser Cache

清除浏览器高速缓存

Normally, to see the changes on your page, you click the Refresh button on the browser toolbar or press the F5 key on your keyboard. In many cases, this simply reloads the page without clearing the browser's cache. Here are some techniques to wipe clean the browser's cache so you will see the changes when your page reloads.

一般情况下,查看你的网页的变化,你点击浏览器工具条上的刷新按钮,或者按你的键盘上的F5键。在大多数情况下,这样做,这样做,只会重新地载入网页,却没有清除浏览器的高速缓存。下面是一些方法用来清除浏览器的高速缓存,这样你的网页再次载入的时候,你就能发现到变化。

Microsoft Internet Explorer 

;Microsoft Internet Explorer :

  1. Hold down SHIFT and click on the REFRESH button in the toolbar under the menu.
  2. 按住SHIFT并且点击菜单下的工具栏中的刷新按钮。
  3. For Serious Clearing: If you are having problems clearing out the cache, then force it by choosing from the menu TOOLS > INTERNET OPTIONS > TEMPORARY FILES. Click on Delete Temporary Files. You can choose the checkbox to delete all Internet files, but you might not want to as that will also clear all your passwords and cookies, but if you are having trouble viewing the changes on your page, go all the way.
  4. 关于认真地清除:如果你清除高速缓存时,遇到了麻烦,在菜单工具> 因特网选项 > 临时文件 中挑选,来强迫地清除高速缓存点击删除临时文件。你也可以选择检验栏来清除所有的因特网文件,但是你也许不想这样做,因为那样的话,也会清除你所有的密码和cookies,但是如果你向看看网页上的改变,有困难的话,就尝试一下所有的方法。
Mozilla Firefox 
Mozilla Firefox 
  1. Hold down CTRL+SHIFT+R.
  1. 按住CTRL+SHIFT+R.
  1. If you are using Chris Pederick's Web Developer Extension, click Miscellaneous and then Clear Cache.
  2. 如果你正使用Chris Pederick的环球网 开发者 扩展,点击 各式各样并且清除高速缓存。
  3. For Serious Clearing: From the browser menu, Tools > Options > Privacy > Cache and select Clear.
  4. 关于认真清除:在浏览器菜单上,工具> 选项 > 私密 > 高速缓存 并且点击清除。
Netscape 
From the menu, click Edit > Preferences > Advanced. Choose "Cache" and click both "Clear Memory Cache" and "Clear Disk Cache".

;Netscape :在菜单上,点击编辑 > 参数选择> 高级的。选择"高速缓存"并且点击"清除记忆存储" 和"清除磁盘存储"。

Mozilla 1.x and up 
From the browser menu, Edit > Preferences > Advanced and click "Cache" and "Clear Cache".
Mozilla 1.x 和更高的 
在浏览器菜单,编辑 > 参数选择 > 高级的 点击"高速缓存" 和 "清除高速缓存"。
Opera 
From the browser menu, Edit > File > Preferences > History and Cache and click "Cache".
Opera 
在浏览器菜单上, 编辑>文件 > 参数选择>历史和高速缓存 点击"高速缓存"。
Safari
From the browser menu, Safari > Reset Safari and click Reset to confirm OR Safari > Empty Cache.
Safari
在浏览器菜单上,Safari > 重新设置Safari 并且点击重新设置 来确认 OR Safari >清空高速缓存。
Miscellaneous 
Each browser may have a way of stopping or minimizing the caching of web pages. Using this technique will definitely slow down your web page viewing, and it isn't a perfect solution because some caching may still occur, but it does help. Check your Internet browser's help files for the specifics on how to turn off the cache feature.

;各式各样的:每个浏览器都可以停止或者将网页上的高速缓存最小化。使用这个技术,的确能使你的网页浏览速度降低,但这不是一个最好的解决方法,因为有的高速缓存可能还会发生,但这也的确能起作用。查看你的因特网浏览器的帮助文件来查看关于怎样关闭高速缓存功能的详细信息。

Check Your Source

查看你的原始资料

You know, even the very best web page designers, developers, and programmers screw up. It's the little details, the forgotten semi-colon, the misspelled tag, the lack of attention to a detail that screws things up. If the best do it, then it's very possible you have overlooked a little detail. And if you did, well, welcome to the club. It's a part of the process. Let's look at some of the most commonly overlooked details that happen when you aren't paying attention.

你也知道,即使是最好的网页设计师,开发人员,和程序员都弄砸了。这是一个小的细节,丢掉的分号,拼错的标签和对一个细节的忽视,使事情弄砸了。最好的情况是,你可能忽略了一个小细节。如果你真的忽略了一个小细节,欢迎来到俱乐部。这是其中的一个过程。让我们来看看你没有注意到的,最常见的一些遭到忽视的细节信息。

Check the Address

查看地址

Is the name and folder for the file you "fixed" the same as the one you are viewing? Look at the following two addresses (URLs). 你给文件"确定的"文件夹和名称与你正浏览的是同一个吗?看一下下面两个地址(URLs)。

  • wordpress/wp-content/themes/yourtheme/style.css
  • test/wordpress/wp-content/themes/yourtheme/style.css



  • wordpress/wp-content/主题/你的主题/style.css
  • test/wordpress/wp-content/主题/你的主题/style.css


In this case, you can probably see the difference, but when viewed in an address bar or in a text editor, you might miss the word test that sets the folder. 在这种情况下,你也许看到了差别,但是当你在一个地址框或者在一个文本编辑器上看的时候,你可能丢掉了设置文件夹的字test

Pay very close attention to the difference between style1.css and stylel.css if you are using different style names, too. The first filename is style followed by the digit one, while the second filename is style followed by a lowercase L. If you are working with different but similar files, make sure you give them distinctive names like style-red.css and style-800.css so you can clearly see the difference. 如果你也使用不同的样式名,密切地注意style1.cssstylel.css之间的区别。第一个文件名style后是一个数字1,而第二个文件名style后是一个小写字母。如果你在使用不同的但是相似的文件,确定你给它们命了独特的名字,像style-red.cssstyle-800.css这样你一目了然地就能看到不同之处。

Check the Template

检查模板

If you're editing a template, are you sure the page you're viewing is being generated from that template? Remember that many templates have very similar text on them; for example, a post header may appear on a single post page, index page, search page, archive page, and others. 如果你编辑一个模板,你确定你看的网页是由那个模板产生的吗?记住许多模板上有非常相似的文本;例如,一个文章的标题可能会出现在一个单独的文章网页上,索引页,搜索页,归档页面,以及其它的页面上。

See WordPress:Template Hierarchy if you're having trouble figuring out which template is in use.

如果你不知道使用的模板是哪一个,看看模板层级

Check Your Upload

检查你的上传

When you make a change in a file, it is often on your computer's hard drive and you have to upload the file to your host server in order to view it on the Internet. Did you actually upload it? Did you put it in the right folder? Is it really there? When over-writing the exact same file, it doesn't always do a complete over-write, so consider deleting the original on the host server and then uploading the new version to make sure the right and whole thing is there.

如果你对文件做了更改,通常会在你的电脑的硬盘上,你要将文件上传到你的主机服务器上,这样你可以在互联网上看到。你真的上传了吗?你将它放进了正确的文件夹吗?它真的在那儿吗?当盖写一个完全相同的文件时,通常并不能完全地盖写,因此考虑在主机服务器上删除原先的文件,然后上传新的版本,要确保那儿有正确的和整个的文件。

Test Yourself

自测

If you still can't see the changes you made, and the file is in the right place with the right name, and you are sure it's the right file, then go through these steps: 如果你还是看不大你做的更改,文件在适当的位置上有合适的名称,你也确定它是正确的文件,那么采取以下的措施:

  1. Make a backup of the file you are working on and check that the backup is in a safe place.
  2. 给你处理的文件备份一下,并且查看一下文件备份是否在安全的位置。
  3. Make a big change (such as setting the background in your style.css as #ff0000 or even red).
  4. 做一个大的更改(例如在你的style.css as #ff0000设置一个背景或者甚至是红色的)。
  5. View the changed web page in your browser. Make sure you clear the cache to be sure you have the new version.
  6. 在你的浏览器上看看改变的网页。确保你清除了高速缓存,确保你有了一个新的版本。
  7. If nothing changes, delete the file (and only that file) from the server and try to view the file again. If nothing continues to change, you and WordPress are looking at completely different files. It's time to get out your detective hat and start tracking down what is going on and where your files went to.
  8. 如果什么都没变,在服务器上删除那个文件(仅仅是那个文件)试着在看看文件。如果还是什么也没变,你和你的WordPress正看着完全不同的文件。是时候取下你的侦探帽了,并且要追踪正发生什么,你的文件哪去了。
  9. Check your URL settings in your Options Panel and also in the database, and if this continues to be unsolvable, post a note explaining what you've done and what's the result on the WordPress Forum and let the experts step in to help.
  10. 在你的选项面板和数据库中查看你的URL设置,如果这个问题还是没有得到解决,在WordPress 论坛上发表一个条子,说明你做了哪些事,以及结果是什么,让专家来插手帮助你。

Debug It

调试它

Programmers use the term debug to describe the process of going through code and finding the little criminal that is messing things up. We're going to look at how to debug your CSS, HTML, and PHP code to help you figure out why you can't see the changes you have made.

程序员使用术语调试来描述检查代码的过程,找出小的将事情弄得一团糟的罪魁祸首。我们将要看看怎样地调试你的CSS,HTML,和PHP代码,来帮助你了解你为什么看不到你做的更改。

When debugging a problem, change only one thing at a time. If you're not sure if the problem is in line 37 or line 40, don't change both lines in one go! First change line 37, and see if that fixed the problem. If not, undo the change you made on line 37 and then make a change on line 40. It's important to undo proposed fixes before trying something else, even if the first attempt doesn't immediately introduce new problems.

调试一个程序的时候,一次只能调试一个。如果你不确定问题出现在37行,还是第40行,不要一次就对两行都做了改变。首先更改一下第37行,看看那个能否解决问题。如果不能解决问题,取消你对第37行做的更改,对第40行改一下。在尝试其它的变化之前,取消已经做的更改非常重要,即使第一次尝试并没有立马地引进新的问题。

Every time you make a change to a file, you run the risk of accidentally making more mistakes. These sorts of things tend to cascade, making debugging an infuriating process. Do one thing at a time.

每次你更改文件,你也冒着意外地增加更多的错误的风险。这些事往往级联,使调试成为一个令人恼人的过程。一次就做一件事。

Debugging CSS

调试CSS

Debugging your style sheet, or your CSS, can be challenging because you have to find the area in the HTML that is causing the trouble and then track that section back to its style in your style.css file. The article on WordPress:Finding Your CSS Styles will help you find those troublesome sections.

调试你的样式表,或者你的CSS,可能具有挑战性,因为你需要在HTML中找到引起那个麻烦的区域,然后在你的style.css 文件,追踪到那个部分的样式。着的你的CSS样式中的文章,会帮你找到哪些引起麻烦的部分。

Once you have found the style that is causing the problem, you need to figure out what it is about the style that is causing the problem. Here is a quick checklist of things to consider as you troubleshoot your CSS:

一旦你找到了那个引起麻烦的样式,你需要了解样式中的什么,引起了麻烦。下面是你检查你的CSS故障时,需要考虑的一些事情的清单:

  • Is everything spelled correctly?
  • 所有的拼写都是正确的吗?
  • Is every period, brace, colon and semi-colon in its right place?
  • 是不是每个点号,大括号,和分号都在合适的位置上?
  • Are you using the style attribute or declaration correctly?
  • 你有没有正确地使用了样式属性或者声明
  • Is there a declaration that shouldn't be in there, like font-weight:x-large? The declaration x-large is used for font-size not font-weight.
  • 有没有一个声明本不应该在那儿,像font-weight:x-large?声明?声明x-large是用来font-size而不是font-weight
  • Do you have spaces in places where they shouldn't be, like inside of a background-image:url ( ' bg.gif ' )? (correct: background-image:url('bg.gif'))
  • 在本没有空格的地方,你是不是添加了空格,像一个background-image:url ( ' bg.gif ' )里面?(正确的:background-image:url('bg.gif'))

You can find more information to help you debug and troubleshoot your CSS with: 你可以在以下中发现更多的信息来帮助你调试和解决你的CSS的故障:

  • 发现并修理故障 你的主题 - 立马到达

Debugging HTML

调试HTML

Similar to debugging CSS, HTML can also get bogged down with careless little mistakes like misspellings, forgotten closing tags, forgotten < arrows, and other little errors that can send your site into twisted remains. 与调试CSS类似,HTML也会因为一些粗心的小错误,而不能使用,像拼写错误,忘了关掉标签,忘了forgotten <箭头符号,和其它的小错误,会是你的站点变得混乱。 It is highly recommended that you use one of the HTML Validators available for free on the Internet. Also, Mozilla Firefox has a powerful free add-on (actually bundled with most Firefox installations) called the Web Developers DOM Inspector that will help you validate and fix your website problems very quickly and easily.

Some tips for debugging your HTML/XHTML may include: 强烈推荐你使用网上免费的HTML Validators。而且Mozilla Firefox有一个强大的免费add-on(事实上与大多数Firefox是绑定在一起的)叫做网络开发者DOM 检查器会帮助你快速地,轻易地确认并且解决你的网站问题。

  • Improperly nested XHTML, especially in nested lists commonly found in the sidebar.
  • 没有适当地嵌套XHML,特别是在嵌套列表通常可在工具条中找到。
  • Unclosed tags.
  • 为关闭的标签。
  • Self-closing tags not closed by use of the forward slash (example: <img src="ball.gif" />).
  • 自动关闭的标签,不是使用斜线关闭(例如:<img src="ball.gif" />).
  • Incorrect tag usage.
  • 错误地使用标签。

For more help on debugging your HTML, check out these articles and resources: 关于调试你的HTML的更多的帮助,查看以下的这些文章和资源:

Debugging PHP

调试PHP

If you have access to your webserver's error log, take time to check it. PHP usually logs informative errors here when things go wrong. These log messages can sometimes be a little cryptic, but they should always give the line number of the offending piece of code. 如果你有权限进入你的网络服务器的误差记录,花一点时间查看一下。当什么东西出错了的时候,PHP通常会在这儿记录错误的信息。这些记录的信息有时候有一点模糊,但是它们应该总是给出违规的代码的行数。

Unfortunately, what PHP thinks is the offending piece of code is sometimes not the problem. For example, an unclosed curly brace { may be reported as a problem on some line number way on down in your script. A quick cheat sheet of PHP error messages and their common causes can be found at Common PHP Errors. 不幸地是,PHP认为的违规的代码有时并不是一个问题。例如,没有关闭的花括号{在你的脚本某行中可能被报导为一个错误。在常见的 PHP错误中可以找到一些PHP错误信息的快捷作弊表。 To debug your PHP, here are the steps you should follow: 调试你的PHP,下面是一些你需要遵循的步骤:

See Where You Are

看看你出的位置

The die() command is probably the single most useful debugging tool available. die() immediately halts execution of the program, optionally displaying a message of your choosing.

die()命令行可能是唯一最有用的调试工具。die()立马地停止程序的执行,随意地显示一个你选择的信息。

When trying to work through problems, sprinkle die() statements in at key sections of your script, giving each an informative message:
当试着解决这些问题的时候,在你的脚本的一个关键的部分,散步die()声明,给每个一个翔实的信息:

die('Stage One Complete');
die('Disinfribullation Complete');
die('Finished Collating');



die('Stage One Complete');
die('Disinfribullation Complete');
die('Finished Collating');


Load your program, and see which message (if any) gets displayed. If you see the first message, you know your program got that far without error. You can safely remove (or comment out) that die() command, and re-run your program, to see how much farther it got. Step through your program this way until you've isolated the problem area.

载入你的程序,看看那个信息(如果存在的话)显示了。如果你看到了第一个信息,你知道你的程序运行到那里也没有一个错误。你可以安全地移除(或者评论除去)那个die()命令行,并且重新地运行你的程序,看看它运行到了哪里。以这种方式来处理你的程序,直到你隔离了问题区。

This technique has some limitations, though. First, if nothing is being displayed in your browser, then most likely you have a fatal syntax error somewhere in your script. Check your webserver's error log, if possible. If the script executes completely -- but incorrectly -- and none of your die() messages are displayed, then you've got some more work to do. 但是这个方法也有一些限制。首先,如果你的浏览器上什么也没有显示,你的脚本的某处可能有重大的语法错误。如果可以的话,查看你的网络服务器的错误记录。如果脚本完全地执行了—但是错误地—而且你的die()消息什么也没有显示,那么你就需要做更多的事。

See What's What

看看什么是什么

If things aren't being set as you want them, or stuff isn't happening when you want, you'll likely need to check the value of different variables at different places of your script. Simply pass the variable to a die() command, and you'll be able to see what that variable's value is:

die($user_level);

如果事情不是按你所想的设置的,而且当你想要原料是也没有,你可能要在你的脚本的不同位置上查看不同的变量的值。只要将变量传到一个die()命令行,你就能看到那个变量的数值:

die($user_level);

This will display the value of the variable $user_level, which should reveal the current user's user level. 这样会显示不同的$user_level的值,可以显示目前用户的级别。

This technique is fine for some variable types, like boolean and string ("scalar") variables in programmer parlance; but fails for arrays and objects. To see the value(s) of arrays and objects, use the print_r command:
对于一些变数类型,像boolean和string,这个方法较好("scalar")一个程序员用法中的变数;但是对arraysobjects不管用。看看数组和对象的值,使用print_r command:

print_r($post);
print_r($post);

It will display the value of the $post array in a human-readable format: 它会以人们易读的方式显示$post数组的值:

Array ( [0] => stdClass Object ( [ID] => 1 [post_author] 
=> 1 [post_date] => 2005-02-16 09:16:46 [post_date_gmt] 
=> 2005-02-16 14:16:46 [post_content] => Welcome to 
WordPress. This is your first post. Edit or delete it, 
then start blogging! [post_title] => Hello world! [post_category] 
=> 0 [post_excerpt] => [post_status] => publish [comment_status] 
=> open [ping_status] => open [post_password] => [post_name] 
=> hello-world [to_ping] => [pinged] => [post_modified] => 2005-04-15 
08:45:42 [post_modified_gmt] => 2005-04-15 13:45:42 
[post_content_filtered] => [post_parent] => 0 [guid] 
=> /?p=1 [menu_order] => 0 ) )



Array ( [0] => stdClass Object ( [ID] => 1 [文章作者] 
=> 1 [post_date] => 2005-02-16 09:16:46 [post_date_gmt] 
=> 2005-02-16 14:16:46 [post_content] => Welcome to 
WordPress. This is your first post. Edit or delete it, 
then start blogging! [post_title] => Hello world! [post_category] 
=> 0 [post_excerpt] => [post_status] => publish [comment_status] 
=> open [ping_status] => open [post_password] => [post_name] 
=> hello-world [to_ping] => [pinged] => [post_modified] => 2005-04-15 
08:45:42 [post_modified_gmt] => 2005-04-15 13:45:42 
[post_content_filtered] => [post_parent] => 0 [guid] 
=> /?p=1 [menu_order] => 0 ) )


This format allows you to see what each key/value pair is inside the array. 这个格式可以让你看看数组中的每个关键/值对。 Using print_r() does not stop execution of the program, so it is often necessary to call die() immediately afterwards.

使用print_r()不会阻止程序的运行,因此随后立马访问die()通常是有必要的。 Use print_r() and die() to check the values of your variables through the execution of your script. There's also a var_dump() function which works similarly. Use whichever mechanism you find most informative. 通过执行脚本,使用print_r()die()来检查你的变量的值。有一个var_dump()功能,它的运行也相似。使用你找到的任何最翔实的机制。

When All Else Fails

其它所有的都不运行

If all else fails, know this: You are not alone. We've all been there. To help you get back on track and your site up and running again, check the following resources for more help: 如果其它所有的都不运转,了解:你不是独自的。我们都在那儿。帮你返回,是你的站点再次启用,再次运行,查看一下的资源得到更多的帮助:



This article is [[WordPress::Category:Copyedits|marked]] as in need of editing. You can help Codex by editing it.

留言