天天看點

查找wordpress端口_如何在WordPress主題中查找要編輯的檔案

查找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主題查找要編輯的檔案。

查找wordpress端口_如何在WordPress主題中查找要編輯的檔案

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管理欄中看到一個新的“檔案内容”菜單。

查找wordpress端口_如何在WordPress主題中查找要編輯的檔案

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.

現在,您隻需将滑鼠移到菜單項上,它将顯示一個下拉菜單,列出用于顯示此頁面的模闆檔案。

查找wordpress端口_如何在WordPress主題中查找要編輯的檔案

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視訊教程。 您也可以在Twitter和Facebook上找到我們。

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

查找wordpress端口