查找wordpress端口_如何在WordPress主题中查找要编辑的文件

查找wordpress端口

Recently, one of our readers asked how do you find which files to edit in their WordPress theme? If you are new to WordPress theme development and want to customize your theme, then you need to learn which template files in your theme you need to edit. In this article, we will show you how to easily find which files to edit in WordPress theme.

最近,我们的一位读者问您如何找到以WordPress主题编辑的文件? 如果您不熟悉WordPress主题开发,并且想要自定义主题,那么您需要了解主题中需要编辑的模板文件。 在本文中,我们将向您展示如何轻松地以WordPress主题查找要编辑的文件。

How to find which WordPress theme files to edit
WordPress主题中的模板文件 (Template Files in WordPress Themes)

WordPress themes control how your website looks to your users. Each theme contains several template files which control the appearance of a particular section or page in your WordPress theme.

WordPress主题控制着网站对用户的外观。 每个主题包含几个模板文件,这些模板文件控制WordPress主题中特定部分或页面的外观。

For example, single.php file controls the appearance of single posts on your website. It is not the only file to do that.

例如, single.php文件控制网站上单个帖子的外观。 它不是执行此操作的唯一文件。

If your theme does not have a single.php file, then WordPress will look for alternate templates like index.php to display the page.

如果您的主题没有single.php文件,则WordPress将寻找index.php之类的替代模板来显示页面。

Most beginners are not familiar with template hierarchy in WordPress. This makes it harder for them to figure out which files to edit when they want to customize their themes.

大多数初学者不熟悉WordPress中的模板层次结构。 这使他们在想要自定义主题时很难确定要编辑的文件。

Having said that, let’s see how to easily find out which files to edit in your WordPress theme.

话虽如此,让我们看看如何轻松地找到要在WordPress主题中编辑的文件。

在WordPress主题中查找模板文件 (Finding Template Files in WordPress Themes)

First thing you need to do is install and activate the What The File plugin. For more details, see our step by step guide on how to install a WordPress plugin.

您需要做的第一件事是安装并激活What The File插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。

The plugin works out of the box, and there are no settings for you to configure.

该插件可以直接使用,没有可供您配置的设置。

Upon activation, you need to visit your website and you will notice a new ‘What the file’ menu in WordPress admin bar.

激活后,您需要访问您的网站,您会在WordPress管理栏中看到一个新的“文件内容”菜单。

What the file menu in WordPress admin bar

Now you need to just take your mouse over to the menu item, and it will display a drop down menu listing the template files used to display this page.

现在,您只需将鼠标移到菜单项上,它将显示一个下拉菜单,列出用于显示此页面的模板文件。

Template files used to display this page

Clicking on the file name will take you to the default WordPress file editor where you can edit that particular file.

单击文件名将带您到默认的WordPress文件编辑器,您可以在其中编辑该特定文件。

However, we do not recommend using WordPress file editor to edit theme files because there is no undo option. If you accidentally lock yourself out of your website, then you would have to use a FTP client. That’s why we always using a FTP client and plain text editor to edit your files.

但是,我们不建议使用WordPress文件编辑器来编辑主题文件,因为没有撤消选项。 如果您不小心将自己锁定在网站之外,则必须使用FTP客户端。 因此,我们始终使用FTP客户端和纯文本编辑器来编辑文件。

Making direct changes to your WordPress theme is also a bad idea. Those changes will disappear when you update your theme.

直接更改WordPress主题也是一个坏主意。 当您更新主题时,这些更改将消失。

If you are just adding some CSS, then you can add it as custom CSS in WordPress. For all other changes you should create a child theme.

如果您只是添加一些CSS,则可以在WordPress中将其添加为自定义CSS 。 对于所有其他更改,您应该创建一个子主题

‘What The File plugin’ can help you locate the theme files that you need to copy and edit in your child theme.

“文件插件”可以帮助您找到子主题中需要复制和编辑的主题文件。

Note: The menu item added by the plugin in the admin bar will be visible to all logged in users, and it has a link to an external site. You should only use this plugin in development environment.

注意:插件在管理栏中添加的菜单项对所有登录的用户都是可见的,并且具有指向外部站点的链接。 您只应在开发环境中使用此插件。

We hope this article helped you learn how to find which files to edit in WordPress themes. You may also want to see our guide on how to test your WordPress theme against latest standards

我们希望本文能帮助您学习如何在WordPress主题中查找要编辑的文件。 您可能还希望查看我们的指南, 了解如何根据最新标准测试WordPress主题

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/plugins/how-to-find-which-files-to-edit-in-wordpress-theme/

查找wordpress端口

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值