wordpress入门主题
Our last few videos have covered introductions to a few varieties of programming topics, but this one here involves no programming skills at all! If you’re looking to freshen up your blog, put your HTML and CSS skills to the test and build on an existing blog theme.
我们的最后几段视频介绍了一些编程主题,但是这里根本不涉及任何编程技能! 如果您希望刷新博客,请测试您HTML和CSS技能,并以现有的博客主题为基础。
There would seem to be an infinite number of WordPress themes available online. Finding the perfect theme can be a daunting and time consuming task. Why not just choose a theme you like and make a few tweaks to it? WordPress Child Themes allow you to make changes to both the style and functionality of a chosen parent theme.
在线上似乎有无数的WordPress主题。 寻找完美的主题可能是一项艰巨且耗时的任务。 为什么不选择自己喜欢的主题并对其进行一些调整呢? WordPress子主题允许您更改所选父主题的样式和功能。
Tune in below as Harley walks us through how to get started with WP Child Themes. Super simple and effective! Perhaps too simple? rel="stylesheet" type="text/css" href="https://learnable.com/stylesheets/jumpcast.css">
哈雷(Harley)带领我们逐步了解WP儿童主题的入门方法,请在下面进行调整。 超级简单有效! 也许太简单了? rel="stylesheet" type="text/css" href="https://learnable.com/stylesheets/jumpcast.css">
Jess: I’m here with Harley Alexander, who is a WordPress guru at SitePoint. Harley is going to tell us all about child themes today. Hello, Harley.
Jess:我和Harley Alexander在一起,他是SitePoint的WordPress专家。 哈雷今天将向我们介绍所有有关儿童主题的内容。 你好,哈雷。
Harley: What’s up?
哈雷:怎么了?
Jess: First things first. Can you tell us what a WordPress child theme is?
杰西:第一件事。 您能告诉我们WordPress子主题是什么吗?
Harley: Officially, a WordPress child theme is the recommended way to modify, to make modifications to an existing theme. So, say there is a theme you quite like, you want to make some small changes, a child theme is the way to do that.
哈雷:正式地,推荐使用WordPress子主题进行修改,以对现有主题进行修改。 因此,假设有一个您非常喜欢的主题,您想进行一些小的更改,子主题就是实现该主题的方法。
Jess: And why do they call it a child theme?
杰西:为什么他们称其为儿童主题?
Harley: There are two types of themes. There is a child theme and a parent theme, clearly. The child theme basically inherits everything from a parent, just like children do from parents. So it’s a great place to start, and then build on top of.
哈雷:有两种主题。 显然有一个儿童主题和一个父母主题。 子主题基本上继承了父母的一切,就像孩子从父母继承的一样。 因此,这是一个很好的起点,然后再建立于此。
Jess: That makes sense. So would you choose a child theme over a parent theme, then?
杰西:很有道理。 那么,您会选择子主题而不是父主题吗?
Harley: Well, it’s a great way to not actually have to touch any code from the theme that already exists, and to make really small modifications or even add to it, build on the functionality. There’s quite a lot you can do with child themes.
哈雷:嗯,这是一种很棒的方法,它实际上不必从已有的主题中触摸任何代码,而是在功能的基础上进行很小的修改,甚至对其进行添加。 您可以对儿童主题做很多事情。
Jess: And who would be interested in using child themes, then?
杰西:那么谁会对使用儿童主题感兴趣呢?
Harley: Child themes are a great place to start if you don’t really know much about making WordPress themes. So if you don’t really want to start from the very beginning, you can have a great theme already there. For example, 2011, the default WordPress theme, is a great parent theme to start with. And you can just build on top of it really easily, and you don’t really need to learn many skills as well.
哈雷:如果您不太了解制作WordPress主题,那么儿童主题是一个不错的起点。 因此,如果您真的不想从头开始,那么您可以拥有一个很棒的主题。 例如,默认的WordPress主题2011是一个很好的父主题。 而且,您可以真正轻松地在此基础上进行构建,并且您实际上也不需要学习很多技能。
Jess: So, what kind of modifications can you make with a WordPress child theme, then?
杰西:那么,您可以对WordPress子主题进行什么样的修改?
Harley: There are probably two major modifications that you can do, or types of modification. There are visual changes, so changes to the style, font, color, sizing, that kind of thing. There are also functionality modifications, so you can change the way a specific function from the parent theme works, or add on top of it, and include different layout parts as well.
哈雷:您可能可以进行两种主要的修改,或者修改的类型。 视觉上会有变化,因此样式,字体,颜色,大小等都会发生变化。 还进行了功能修改,因此您可以更改父主题的特定功能的工作方式,或在其之上添加,还包括不同的布局部分。
Jess: And what sort of background do you need to start working with these themes?
杰西:您需要什么样的背景来开始这些主题?
Harley: At its most basic, a child theme is just a stylesheet. So, if you only know CSS, then you are pretty well equipped to start making your first child theme.
哈雷:从根本上讲,儿童主题只是样式表。 因此,如果您只了解CSS,那么您就可以开始制作第一个子主题。
Jess: Are there any other sort of skills that would be helpful, though, with using these?
杰西:还有其他技能可以帮助他们吗?
Harley: Absolutely. On top of CSS, it is really good to have basic HTML knowledge, it’s a given. And a solid understanding of WordPress template tags, hooks, and filters, is also great. And PHP definitely comes in handy.
哈雷:当然。 在CSS之上,拥有基本HTML知识确实是一件好事。 对WordPress模板标签,挂钩和过滤器有扎实的了解也很不错。 PHP绝对派上用场。
Jess: So where do I get started, if I want to learn more?
杰西:如果我想了解更多,那我应该从哪里开始呢?
Harley: If you did a basic Google search online, for “how to get started with child themes”, you’d find a plethora of articles that you could learn from. SitePoint’s actually also got a book called “How to Build Your Own Wicked WordPress Theme.”
哈雷:如果您在Google上进行了基本的在线搜索,以查找“如何开始使用儿童主题”,那么您会发现大量可以从中学习的文章。 SitePoint实际上还获得了一本书,名为“如何构建自己的邪恶WordPress主题”。
Jess: So do you want to give us a demo of how to create a child theme, then?
杰西:那么,您想给我们演示一下如何创建儿童主题吗?
Harley: Absolutely. Let’s jump over to my screen.
哈雷:当然。 让我们跳到我的屏幕上。
Jess: Let’s do it!
杰西:开始吧!
Harley: Here I have a fresh install of WordPress that is using the default Twenty-Eleven theme, and Twnety-Eleven is actually going to be our parent theme for today. So, I’m going to jump over into our themes folder, and create a new folder and call it “child theme”. And then within that, I’m going to create a stylesheet, which is called “style.css”.
哈雷:在这里,我有一个全新的WordPress安装,它使用默认的二十一岁主题,而二十一岁十一岁实际上将成为我们今天的父主题。 因此,我将跳至我们的主题文件夹,并创建一个新文件夹并将其称为“子主题”。 然后在其中创建一个样式表,称为“ style.css”。
And as with anything, we need to insert the metadata for that, so I’m going to chuck that in, and we’ll call it “child theme”. None of that’s really important right now. But we do need to add one very important metatag, which is “template”. And in the template you need to specify the parent theme that you are going to be using. So, we’re going to be using “Twenty-Eleven”, just like that.
像其他任何事情一样,我们需要为此插入元数据,因此我将其插入,我们将其称为“子主题”。 目前,这些都不是很重要。 但是我们确实需要添加一个非常重要的元标记,即“模板”。 并且在模板中,您需要指定将要使用的父主题。 因此,正像那样,我们将使用“二十一”。
Cool, so, if we head back to here, and head to the themes page in WordPress admin, our new child theme will show up. Boom, there it is. Brilliant, so we’ll head back home, and you’ll notice that it actually looks pretty bad. And that’s because with any child theme, you need to import the parent theme’s stylesheet in order to inherit it all. So I’m going to go ahead and throw in an import rule, and we’re going to go up a directory into “2011” and then “style.css”. Brilliant. So now, if we head back to our page and refresh, beautiful, it looks like Twenty-Eleven.
很酷,因此,如果我们回到此处,并转到WordPress管理中的主题页面,将会显示我们的新子主题。 繁荣,就在那里。 太棒了,因此我们将返回家中,您会注意到它实际上看起来很糟糕。 这是因为对于任何子主题,您都需要导入父主题的样式表才能继承所有主题。 因此,我将继续执行导入规则,并在目录中依次输入“ 2011”和“ style.css”。 辉煌。 所以现在,如果我们回到页面并刷新,看起来很美,看起来像二十一岁。
So, the next thing we really want to do is just change the background color of this header. I’m going to make it the same color as this border along the top, just for simplicity’s sake. So in our stylesheet we’ll add a new rule, for “branding”, which is this top area up here. And we’re just going to go, background color is triple B.
因此,我们下一步要做的就是更改此标头的背景颜色。 为了简单起见,我将使其与顶部的边框颜色相同。 因此,在样式表中,我们将为“品牌”添加一个新规则,这是此处的最重要的区域。 我们将要去,背景色是三倍B。
All right, so if we save that, and then refresh, our background color is triple B up here. So now you can see, we’ve pretty much just got a brand new theme. Not too different to 2011, but it is different, simply through using “style.css”. You can do pretty much anything, including adding functionality with PHP, but I’m not going to get into that now. I’m just going to fix up this search box, here.
好吧,因此,如果我们保存它,然后刷新,我们的背景色在这里是三倍B。 所以现在您可以看到,我们几乎有了一个全新的主题。 与2011并无太大不同,但仅通过使用“ style.css”就有所不同。 您几乎可以做任何事情,包括使用PHP添加功能,但是我现在不打算讨论。 我将在此处修复此搜索框。
So I want to add a white background to “#s”. So I’m going to go back here, add in another rule, color, make it triple F, save it, and then refresh. It didn’t work. Why is that? Maybe, if we give it importance, save it, boom, there we go. So yeah, it’s really easy to get started making your first child theme. WordPress.org recommends that you use Twenty-Eleven as your first parent for your first child theme, just because it’s got everything you need. You can go as far as you want with them.
因此,我想在“ #s”中添加白色背景。 所以我要回到这里,添加另一个规则,颜色,将其设置为F的三倍,保存,然后刷新。 没用 这是为什么? 也许,如果我们重视它,保存下来,繁荣就可以了。 是的,开始制作第一个孩子主题真的很容易。 WordPress.org建议您将二十一岁作为您的第一个孩子主题的第一位父母,因为这满足了您的所有需求。 您可以和他们一起走得更远。
Jess: That seems pretty simple to me. Thank you so much for your time, Harley.
杰西:对我来说,这似乎很简单。 非常感谢您的宝贵时间,Harley。
This has been Jess Genevieve Brown with Harley Alexander for Learnable.com.
这是Harley Alexander的Jess Genevieve Brown和Learnable.com的合作 。
翻译自: https://www.sitepoint.com/get-started-with-wordpress-child-themes/
wordpress入门主题