Do you want to install a child theme on your WordPress site? Child themes are great for making customizations because they allow you to take advantage of powerful features of a parent theme or framework. In this article, we will show you how to easily install a child theme in WordPress.
您是否要在WordPress网站上安装子主题? 子主题非常适合进行自定义,因为它们使您可以利用父主题或框架的强大功能。 在本文中,我们将向您展示如何在WordPress中轻松安装子主题。
![How to Install a WordPress Child Theme How to Install a WordPress Child Theme](https://i-blog.csdnimg.cn/blog_migrate/7002fa3c9f50068417ac023e6f3d580a.png)
什么是WordPress儿童主题? (What is a WordPress Child Theme?)
WordPress child themes depend on a parent theme or a theme framework. Child themes borrow all features and appearance of their parent theme and can change them without touching the code of parent theme.
WordPress子主题取决于父主题或主题框架 。 子主题借用其父主题的所有功能和外观,并且可以更改它们而无需触及父主题的代码。
Most free and premium WordPress themes come with a lot of customization options. However, sometimes you may still need to manually add code to your theme.
大多数免费和高级WordPress主题都带有很多自定义选项。 但是,有时您可能仍需要手动将代码添加到您的theme 。
If you add code directly to your theme’s files, then your changes will get overwritten when you update your theme. Child themes solve this problem by allowing you to add your customizations in child theme. This way when you update the parent theme, all your changes will remain intact.
如果直接将代码添加到主题文件中,则更新主题时所做的更改将被覆盖。 子主题通过允许您在子主题中添加自定义项来解决此问题。 这样,当您更新父主题时,所有更改将保持不变。
Child themes are more commonly used with WordPress theme frameworks. These frameworks are robust parent themes that offer a solid base for theme developers to build upon.
子主题更常用于WordPress主题框架。 这些框架是强大的父主题,为主题开发人员提供了坚实的基础。
Genesis is one such popular theme framework. There are tons of child themes available for Genesis that you can get from StudioPress.
创世纪就是这样一种流行的主题框架。 您可以从StudioPress获得有关Genesis的大量子主题。
To learn more about WordPress child themes, we recommend you to read our article on what is a WordPress child theme? Pros, cons and more.
要了解有关WordPress子主题的更多信息,建议您阅读有关什么是WordPress子主题的文章。 利弊等等 。
Want to customize your WordPress theme with a child theme of your own? Follow the instructions in our step by step guide on how to create a WordPress child theme.
是否想使用自己的子主题来自定义WordPress主题? 请按照分步指南中有关如何创建WordPress子主题的说明进行操作 。
Having said that, let’s take a look at how to easily install a WordPress child theme.
话虽如此,让我们看一下如何轻松安装WordPress子主题。
步骤1.安装WordPress子主题 (Step 1. Installing the WordPress Child Theme)
Installing the WordPress child theme is no different than installing any other WordPress theme.
安装WordPress子主题与安装任何其他WordPress主题没有什么不同。
Inside your WordPress admin area, head over to Appearance » Themes page and click on the Add New button.
在WordPress管理区域内,转到外观»主题页面,然后单击添加新按钮。
![Add new WordPress theme Add new WordPress theme](https://i-blog.csdnimg.cn/blog_migrate/3f2af216cc199f5a7625e7583d167e09.png)
There are two methods to install your WordPress theme.
有两种安装WordPress主题的方法。
Method 1: If your child theme is available as a free theme on WordPress.org theme directory, then you can look for it by typing its name in the search box.
方法1:如果您的子主题可以作为WordPress.org主题目录上的免费主题使用,则可以通过在搜索框中键入其名称来进行查找。
![Searching for a free WordPress child theme Searching for a free WordPress child theme](https://i-blog.csdnimg.cn/blog_migrate/384ac66b35b15a6f293673f4d88a96b6.png)
From the search results, take your mouse to the theme you were looking for and then click on the Install button.
从搜索结果中,将鼠标移至所需主题,然后单击“安装”按钮。
WordPress will now download and install your child theme.
WordPress现在将下载并安装您的子主题。
It will also look for required parent theme. If the parent theme is also available on WordPress.org theme directory, then it will automatically install it for you.
它还将寻找所需的父主题。 如果父主题在WordPress.org主题目录上也可用,那么它将自动为您安装。
Method 2: If your child theme came as a zip file, then you need to click on the ‘Upload Theme’ button. This will show you theme upload option.
方法2:如果您的子主题是一个zip文件,则需要单击“上传主题”按钮。 这将显示主题上传选项。
![Upload your child theme's zip file Upload your child theme's zip file](https://i-blog.csdnimg.cn/blog_migrate/2707bbc09b94e10ec02830cdaf1b5fe2.png)
Click on choose file to select the theme zip file from your computer and then click on ‘Install Now’ button.
单击选择文件以从计算机中选择主题zip文件,然后单击“立即安装”按钮。
WordPress will now upload the theme zip file from your computer and install it. It will also check if the parent theme is installed. If parent theme is available from WordPress.org theme directory, then it will try to install it. Otherwise, it will let you know that you will need to install parent theme manually.
WordPress现在将从您的计算机上载主题zip文件并进行安装。 它还将检查是否安装了父主题。 如果可以从WordPress.org主题目录获得父主题,则它将尝试安装它。 否则,它将通知您需要手动安装父主题。
![Installing child theme alone Installing child theme alone](https://i-blog.csdnimg.cn/blog_migrate/1da357635ee6f135ad6b5ad531fa50ab.png)
第2步。安装WordPress父主题 (Step 2. Installing WordPress Parent Theme)
WordPress will automatically try to install the parent theme if it is available on WordPress.org theme directory. If it fails to install the parent theme, then you will not be able to activate the child theme. It will show your child theme as broken on the themes page.
如果WordPress.org主题目录中提供了父主题,则WordPress将自动尝试安装父主题。 如果无法安装父主题,则您将无法激活子主题。 它将在主题页面上将您的子主题显示为损坏。
![Broken child theme Broken child theme](https://i-blog.csdnimg.cn/blog_migrate/2c79fd5b64898d5f80d71a4e5faf5be7.png)
Here is how you will install your parent theme. First go to your parent theme’s website and download the theme zip file.
这是安装父主题的方法。 首先转到父主题的网站并下载主题zip文件。
Now head over to Appearance » Themes page and click on the Add New button.
现在转到外观»主题页面,然后单击添加新按钮。
![Add new WordPress theme Add new WordPress theme](https://i-blog.csdnimg.cn/blog_migrate/3f2af216cc199f5a7625e7583d167e09.png)
Click on the ‘Upload Theme’ button. This will show you theme upload option.
点击“上传主题”按钮。 这将显示主题上传选项。
Click on the choose file button to select the theme zip file from your computer and then click on the ‘Install Now’ button.
单击选择文件按钮以从计算机中选择主题zip文件,然后单击“立即安装”按钮。
![Upload your parent theme's zip file Upload your parent theme's zip file](https://i-blog.csdnimg.cn/blog_migrate/842b37158fc5879e5a09594a64dc4429.png)
After installing both parent and child themes, you can go ahead and activate the child theme.
在安装了父主题和子主题之后,您可以继续激活子主题。
Note: Keep in mind that you don’t need to activate the parent theme in order to use the child theme.
注意 :请记住,使用子主题不需要激活父主题。
We hope this article helped you learn how to install a WordPress child theme. You may also want to see our guide on how to how to find which files to edit in WordPress theme.
我们希望本文能帮助您学习如何安装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/beginners-guide/how-to-install-a-wordpress-child-theme/