wordpress - 如何访问和编辑 index.php 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27242230/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 11:02:26  来源:igfitidea点击:

wordpress - how to access and edit index.php file

wordpressindexing

提问by Matt Wilson

Is there a way to edit the index.php file in wordpress?

有没有办法在wordpress中编辑index.php文件?

Around the web i found a lot of post saying to go to appearance -> editor,

在网上我发现很多帖子说去外观 - >编辑器,

but I can't find this menu... maybe this feature was removed...

但我找不到这个菜单...也许这个功能被删除了...

So how can I do it?

那么我该怎么做呢?

回答by Anoop Asok

Please do this.

请这样做。

Go to WordPress Installation directory. Follow the path wp-content> themes. Open your theme folder. In that you can see index.phpfile. Edit it and save.

转到 WordPress 安装目录。按照路径wp-content> themes。打开您的主题文件夹。在那你可以看到index.php文件。编辑并保存。

回答by Matt Wilson

There are two ways you can edit your PHP files.

有两种方法可以编辑 PHP 文件。

Method 1: Edit the file in your Installation Directory on the Web Server(this is what Anoop Asok is talking about)

方法一:在你的Web服务器上的安装目录中编辑文件(这就是Anoop Asok所说的)

Go to WordPress Installation directory. Follow the path wp-content > themes. Open your theme folder. In that you can see index.php file. Edit it and save.

转到 WordPress 安装目录。按照路径 wp-content > 主题。打开您的主题文件夹。您可以在其中看到 index.php 文件。编辑并保存。

Method 2: Edit the file from the WP Dashboard(This is easier and is what you were trying to do but that file isn't always made available by your theme)

方法 2:从 WP 仪表板编辑文件(这更容易,也是您尝试执行的操作,但您的主题并不总是提供该文件)

  • Download, install, and activate the Synchi plugin (this is an awesome IDE and one of its nice features is that it will allow you advanced theme editing)
  • Go to Appearance > Editor . Now you will see the -themes- window on the right and you will have full access to all your theme files.
  • Double-click your theme and drill down until you find your file you want to edit
  • 下载、安装和激活 Synchi 插件(这是一个很棒的 IDE,它的一个不错的功能是它允许您进行高级主题编辑)
  • 转到外观 > 编辑器。现在您将在右侧看到 -themes- 窗口,您将拥有对所有主题文件的完全访问权限。
  • 双击您的主题并向下钻取,直到找到您要编辑的文件

NOTE!You should avoid editing your theme files because they might be over-written next time you update your theme. Make a child themeand put a copy of index.php in there and work off that one instead.

笔记!您应该避免编辑您的主题文件,因为它们可能会在您下次更新主题时被覆盖。制作一个子主题并将 index.php 的副本放在那里,然后改掉那个。