beginner-wordpress-user/subtitles/Using template parts.bilingual.en-zh.srt
studio 4cfcf09a97 sync: full archive from pipeline (250 files)
Sources: video-subtitle-pipeline artifacts/beginner-wordpress-user/
- subtitles/: en, zh, bilingual SRT/ASS (100 files)
- platform/: youtube SRT + bilibili BCC per video (75 files)
- manifests/: per-video manifest.json (25 files)
- quality/: quality reports (50 files)
2026-04-13 23:35:08 +08:00

400 lines
13 KiB
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

1
00:00:00,000 --> 00:00:05,000
在本课中,我们将更仔细地了解如何使用模板部分。
In this lesson, we will take a closer look at using template parts.
2
00:00:05,000 --> 00:00:11,889
在本教程结束时,你将能够描述模板部分是什么,以及它们如何工作,
By the end of this tutorial, you'll be able to describe what template parts are, and how they work,
3
00:00:11,889 --> 00:00:17,000
编辑一个模板部分,并在模板上替换一个模板部分。
edit a template part, and replace a template part on a template.
4
00:00:17,000 --> 00:00:24,000
如果你访问一个设计良好的网站,你会注意到它的优势之一是其一致性。
If you visit a well-designed website, you'll notice that one of its strengths is its consistency.
5
00:00:24,000 --> 00:00:29,909
它的页眉、页脚和边栏通常具有相同或非常相似的内容,
Its headers, footers, and sidebars often have the same or very similar content
6
00:00:29,909 --> 00:00:37,000
以便访客无论身处网站的哪个位置,都能轻松找到他们需要的信息。
to make it easy for viewers to find the information they are looking for, no matter where they are on a website.
7
00:00:37,000 --> 00:00:45,000
为了实现这种效果,网页设计师是否必须在网站的每个页面上从头开始构建页眉、页脚和边栏?
To get this effect, do web designers have to build their headers, footers, and sidebars from scratch on every page in their website?
8
00:00:45,000 --> 00:00:53,000
简短的回答是不用。使用 WordPress 区块主题时,你会使用一个称为模板部分的功能。
The short answer is no. With WordPress block themes, you will use a feature known as template parts.
9
00:00:53,000 --> 00:00:56,000
首先,什么是模板部分?
Firstly, what are template parts?
10
00:00:56,000 --> 00:01:03,179
模板部分是一组区块,你可以用它们来创建模板中重复的部分,
Template parts are groups of blocks that you can use to create repeated parts of your template,
11
00:01:03,179 --> 00:01:06,000
比如页眉、页脚和边栏。
like the header, footer, and a sidebar.
12
00:01:06,000 --> 00:01:11,600
让我们实际操作一下,当你在 WordPress 仪表盘中时,
Let's see this in action when you're in your WordPress dashboard,
13
00:01:11,600 --> 00:01:14,000
找到外观,然后点击编辑器。
make your way to appearance, and then click on editor.
14
00:01:14,000 --> 00:01:19,128
这将带我们进入站点编辑器,然后我们将打开一个模板,
This will take us to the site editor, and then we'll open up one of our templates,
15
00:01:19,128 --> 00:01:22,000
在这个例子中是博客首页模板。
in this case the blog home template.
16
00:01:22,000 --> 00:01:29,000
在模板内部,我们创建和修改页眉和页脚模板部分。
And within a template, we create and modify our header and footer template parts.
17
00:01:29,000 --> 00:01:35,692
有些区块主题提供的选项或多或少,但几乎都预装了页眉和页脚,
Some block themes provide more or fewer options, but almost all come pre-packaged with the header and footer
18
00:01:35,692 --> 00:01:41,000
就像你在这里看到的,作为 2024 主题的一部分。
like you see here as part of the 2024 theme.
19
00:01:41,000 --> 00:01:45,773
WordPress 通过提供页眉和页脚样板,使其变得更加简单,
WordPress has made it even more simple by providing header and footer patterns
20
00:01:45,773 --> 00:01:48,000
这些样板可以直接使用和修改。
that are ready to be used and modified.
21
00:01:48,000 --> 00:01:55,000
所以,当你点击页眉模板部分的三个垂直点并选择替换页眉时,
So when you click on the three vertical dots of the header template part and select replace header,
22
00:01:55,000 --> 00:01:59,000
你会注意到顶部有现有的模板部分。
you will notice at the top existing template parts.
23
00:01:59,000 --> 00:02:03,000
这些是我已经创建的模板部分。
And these are template parts that I've already created.
24
00:02:03,000 --> 00:02:08,000
然后在它下面,我们会找到页眉模板部分样板。
And then below that, we will find header template part patterns.
25
00:02:08,000 --> 00:02:10,640
当然,现在你将能够选择
And now of course, you will be able to select
26
00:02:10,640 --> 00:02:14,000
你的主题附带的任意这些样板。
any of these patterns that come with your theme.
27
00:02:14,000 --> 00:02:19,000
如前所述,有些主题可能提供得多一些,有些少一些。
And as mentioned, some themes might provide more, some less.
28
00:02:19,000 --> 00:02:24,000
这对于页脚的工作原理完全相同。
And this works exactly the same for footers.
29
00:02:24,000 --> 00:02:27,000
让我们从编辑一个页眉模板部分开始。
Let's start by editing a header template part.
30
00:02:27,000 --> 00:02:30,068
当你在博客工具栏中点击编辑时,
When you click on edit in the blog toolbar,
31
00:02:30,068 --> 00:02:36,000
你可以在编辑模式下处理你的页眉模板部分,不受任何其他干扰。
you can work on your header template part in editing mode without any other distractions.
32
00:02:36,000 --> 00:02:39,000
首先,让我们打开列表视图。
Firstly, let's open our list view.
33
00:02:39,000 --> 00:02:45,000
然后我将继续把我的站点标志添加到我的页眉模板部分。
And then I'll go ahead and add my site logo to my header template part.
34
00:02:45,000 --> 00:02:48,857
所以一旦我选择了站点标志区块,
So once I select the site logo block,
35
00:02:48,857 --> 00:02:54,000
我就可以从我的媒体库或电脑上传一张图片。
I can upload an image from my media library or from my computer.
36
00:02:54,000 --> 00:03:02,000
接下来,我将选择站点标题区块并为这个网站添加站点标题。
Next, I'll select the site title block and add the site title for this website.
37
00:03:02,000 --> 00:03:09,000
然后我将保存我的页眉模板部分并返回到我的博客主页模板。
Then I will save my header template part and return to my blog home template.
38
00:03:09,000 --> 00:03:16,000
提醒一下,模板部分是同步的,会在它被使用的所有地方更新。
Just a reminder, template parts are synced and will update everywhere it has been used.
39
00:03:16,000 --> 00:03:22,000
你会注意到紫色表示一个区块样板何时是同步的。
You will notice that the color purple indicates when a pattern is synced.
40
00:03:22,000 --> 00:03:26,000
让我们去另一个模板看看这个的实际效果。
Let's go to one of our other templates to see this in practice.
41
00:03:26,000 --> 00:03:29,200
所以,例如当我们打开页面模板时,
So when we open our page template for example,
42
00:03:29,200 --> 00:03:32,000
我们会看到页眉是完全一样的。
we'll see the header is exactly the same.
43
00:03:32,000 --> 00:03:39,381
或者当我们打开 404 模板时,我们会看到更改也应用到了这里,
Or when we open up our 404 template, we'll see that the changes have also applied here
44
00:03:39,381 --> 00:03:42,000
因为模板部分是同步的。
because template parts are synced.
45
00:03:42,000 --> 00:03:45,871
假设你希望主页使用不同的页眉,
What if you wanted a different header on say your home page for example,
46
00:03:45,871 --> 00:03:50,000
但希望网站其余部分保留标准页眉。
but you would like the rest of your website to have a standard header.
47
00:03:50,000 --> 00:03:56,519
在这种情况下,你需要创建一个新的页眉模板部分,或用区块样板替换页眉,
In this case, you would want to create a new header template part or replace the header with a pattern
48
00:03:56,519 --> 00:04:01,000
然后将其添加到你的博客主页模板或首页模板中。
and add it to your blog home template or your front page template.
49
00:04:01,000 --> 00:04:04,250
我将修改我的博客主页模板,
I'm going to modify my blog home template
50
00:04:04,250 --> 00:04:09,000
因为我已选择文章页面作为我的主页显示。
as I've selected my posts page as my home page display.
51
00:04:09,000 --> 00:04:12,800
所以我会确保选中页眉,点击三个垂直点,
So I will make sure I select my header, click on the three vertical dots
52
00:04:12,800 --> 00:04:15,000
然后选择“替换页眉”。
and then select replace header.
53
00:04:15,000 --> 00:04:21,000
现在你可以使用样板或现有模板部分来替换主页页眉。
And now you can replace your home page header by using a pattern or an existing template part.
54
00:04:21,000 --> 00:04:30,000
我将用一个已创建的名为“横幅页眉”的现有页眉模板部分来替换。
I will replace the header with an existing header template part which I've already created called banner header.
55
00:04:30,000 --> 00:04:35,000
现在我的主页将拥有自己独特的页眉。
And now my home page will have its own unique header.
56
00:04:35,000 --> 00:04:42,941
一旦我保存后,我们可以查看其他模板,
And once I've saved, we can view our other templates
57
00:04:42,941 --> 00:04:50,000
以再次确认它们仍保留着标准页眉。
to double check that they still have the standard header in place.
58
00:04:50,000 --> 00:04:55,000
最后,我们来谈谈如何从头创建一个模板部分。
Lastly, let's talk about creating a template part from scratch.
59
00:04:55,000 --> 00:05:03,000
前往样板,然后向下滚动到模板部分。
Make your way to patterns and then scroll down to template parts.
60
00:05:03,000 --> 00:05:11,000
在这里你可以查看所有现有的页眉、页脚和通用模板部分。
Here you can view all your existing headers, footers and general template parts.
61
00:05:11,000 --> 00:05:17,286
要创建新的模板部分,点击区块样板旁边的加号图标,
To create a new template part, click on the plus icon next to patterns
62
00:05:17,286 --> 00:05:21,000
然后选择“创建模板部分”。
and then select create template part.
63
00:05:21,000 --> 00:05:27,170
从这里,你可以选择一个不绑定到任何特定区域的通用模板部分,
And from here, you can select a general template part which is not tied to any particular area,
64
00:05:27,170 --> 00:05:31,000
一个页眉模板部分或一个页脚模板部分。
a header template part or a footer template part.
65
00:05:31,000 --> 00:05:35,000
在这个例子中,我们将创建一个页脚模板部分。
In this case, we are going to create a footer template part.
66
00:05:35,000 --> 00:05:40,385
首先,我们需要给它起个合适的名字,比如叫四列页脚,
So firstly, we need to name it appropriately, in this case, a four column footer
67
00:05:40,385 --> 00:05:44,908
然后点击创建,这会把我们再次带入专注模式,
and then we can click create and this will take us into focus mode again
68
00:05:44,908 --> 00:05:49,000
从这里开始,我们就可以从头开始构建了。
and from here, we can start building from scratch.
69
00:05:49,000 --> 00:05:54,000
我打算走个捷径,直接从区块样板目录里抓取一个样板。
I'm going to take a shortcut and actually grab a pattern from the patterns directory.
70
00:05:54,000 --> 00:06:01,440
所以,请访问 WordPress.org点击扩展并选择样板
So make your way to WordPress.org, click on extend and select patterns
71
00:06:01,440 --> 00:06:06,000
从这里,你可以从数千个样板中进行选择。
and from here, you can select from thousands of patterns.
72
00:06:06,000 --> 00:06:16,000
我会选择社区贡献,点击页脚,然后你就可以搜索合适的样板了。
I will select community contributions, click on footers and then you can search for the right pattern.
73
00:06:16,000 --> 00:06:25,000
一旦你找到一个喜欢的样板,就可以复制它,回到你的网站并粘贴,
Once you find a pattern that appeals to you, you can copy the pattern, return to your website and paste
74
00:06:25,000 --> 00:06:31,000
现在你就可以开始修改它以满足你的需求了。
and now you can start modifying it to meet your needs.
75
00:06:31,000 --> 00:06:35,333
一旦更新完成,我们就可以返回到样板区域,
And once updated, we can return to the patterns area
76
00:06:35,333 --> 00:06:40,533
你会注意到你的新页脚已成为现有模板部分的一部分,
and you will notice that your new footer is part of your existing template parts
77
00:06:40,533 --> 00:06:44,000
并且你可以把它添加到任何模板中。
and you can add it to any template.
78
00:06:44,000 --> 00:06:52,727
当你选择管理所有模板部分时,你将能够重命名和删除自定义模板部分,
When you select manage all template parts, you will be able to rename and delete custom template parts
79
00:06:52,727 --> 00:06:59,000
或者清除由你的主题提供的模板部分的自定义设置。
or clear the customizations of template parts that were provided by your theme.
80
00:06:59,000 --> 00:07:06,000
我相信你现在已经能自如地编辑模板,并为你的站点创建页眉和页脚了。
I trust you now feel comfortable editing your templates and creating a header and footer for your site.