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)
560 lines
18 KiB
Text
560 lines
18 KiB
Text
1
|
|
00:00:00,000 --> 00:00:04,000
|
|
在本节课中,我们将更深入地探讨模板。
|
|
In this lesson, we will delve deeper into templates.
|
|
|
|
2
|
|
00:00:06,000 --> 00:00:10,988
|
|
在本教程结束时,我们希望您能区分页面和模板,
|
|
At the end of this tutorial, we want to be able to differentiate between pages and templates,
|
|
|
|
3
|
|
00:00:10,988 --> 00:00:16,429
|
|
知道如何修改我们的基础模板之一,如何添加新模板,
|
|
know how to modify one of our base templates, how to add a new template,
|
|
|
|
4
|
|
00:00:16,429 --> 00:00:21,417
|
|
以及最后,如何将自定义模板分配给页面或文章。
|
|
and lastly, how to assign a custom template to a page or post.
|
|
|
|
5
|
|
00:00:21,417 --> 00:00:26,000
|
|
模板为页面的显示方式提供了结构。
|
|
A template provides the structure for how a page is displayed.
|
|
|
|
6
|
|
00:00:26,000 --> 00:00:36,000
|
|
这通常包括页眉模板部分、内容区域和页脚模板部分。
|
|
That usually includes a header template part, a content area, and a footer template part.
|
|
|
|
7
|
|
00:00:38,000 --> 00:00:42,000
|
|
我认为从一开始就澄清以下信息很重要。
|
|
I think it is important to clarify the following information from the start.
|
|
|
|
8
|
|
00:00:42,000 --> 00:00:44,378
|
|
模板并非用于发布内容,
|
|
Templates are not for posting content,
|
|
|
|
9
|
|
00:00:44,378 --> 00:00:50,000
|
|
而文章或页面的模板会通过文章内容区块来显示您的内容。
|
|
and templates for a post or page display your content with the post content block.
|
|
|
|
10
|
|
00:00:50,000 --> 00:00:53,267
|
|
模板,顾名思义,是设计模板,
|
|
Templates are, as the name implies, design templates
|
|
|
|
11
|
|
00:00:53,267 --> 00:00:57,000
|
|
可以应用于单个或多个页面和文章。
|
|
that can be applied to single or multiple pages and posts.
|
|
|
|
12
|
|
00:00:58,000 --> 00:01:02,000
|
|
要访问模板,请转到外观并点击编辑。
|
|
To access templates, make your way to Appearance and click on Editor.
|
|
|
|
13
|
|
00:01:02,000 --> 00:01:05,000
|
|
这将带您进入站点编辑器。
|
|
This will take you to your site editor.
|
|
|
|
14
|
|
00:01:06,000 --> 00:01:19,186
|
|
编辑器可用于自定义整个网站的样式、编辑页面、修改模板,
|
|
The editor can be used to customize the styles of your entire site, edit pages, modify templates,
|
|
|
|
15
|
|
00:01:19,186 --> 00:01:27,000
|
|
以及管理您网站上的所有不同区块样板。
|
|
as well as manage all the different patterns on your site.
|
|
|
|
16
|
|
00:01:30,000 --> 00:01:35,720
|
|
当您开始构建新网站时,可以编辑现有模板或添加新模板,
|
|
When you start building a new website, you can edit existing templates or add new ones,
|
|
|
|
17
|
|
00:01:35,720 --> 00:01:41,000
|
|
而您使用的主题将决定哪些现有或内建模板可供使用。
|
|
and the theme you are using will determine which existing or built-in templates are available to use.
|
|
|
|
18
|
|
00:01:41,000 --> 00:01:49,000
|
|
所以首先是页面模板,它为单个页面的显示方式创建结构。
|
|
So first up is the page template, which creates the structure for how individual pages will be displayed.
|
|
|
|
19
|
|
00:01:51,000 --> 00:01:59,000
|
|
接下来是单篇文章模板,它用于显示单篇博客文章。
|
|
Next is the single post template, which displays a single blog post.
|
|
|
|
20
|
|
00:02:03,000 --> 00:02:13,000
|
|
索引模板用于显示文章,而 404 模板在未找到内容时显示。
|
|
The index template displays posts, and the 404 template displays when no content is found.
|
|
|
|
21
|
|
00:02:14,000 --> 00:02:18,000
|
|
当然,所有这些模板都可以按您的意愿进行修改。
|
|
And these templates can of course all be modified as you please.
|
|
|
|
22
|
|
00:02:19,000 --> 00:02:23,000
|
|
此外,还有其他值得探索的内建模板。
|
|
Then there are also other built-in templates worth exploring.
|
|
|
|
23
|
|
00:02:23,000 --> 00:02:25,000
|
|
例如,一个空白模板。
|
|
For example, a blank template.
|
|
|
|
24
|
|
00:02:28,000 --> 00:02:33,000
|
|
要添加新模板,请点击模板旁边的插入器或加号图标。
|
|
To add a new template, click on the Insertor or Plus icon next to templates.
|
|
|
|
25
|
|
00:02:33,000 --> 00:02:37,000
|
|
会出现一个模态框,你可以在不同的模板选项之间进行选择。
|
|
A modal appears where you can choose between different template options.
|
|
|
|
26
|
|
00:02:37,000 --> 00:02:40,857
|
|
例如,你可以为特定页面创建一个模板,
|
|
You can, for example, create a template for a specific page,
|
|
|
|
27
|
|
00:02:40,857 --> 00:02:46,000
|
|
或为所有文章分类创建一个模板,或为单个分类创建。
|
|
or a template for all your post categories, or an individual category.
|
|
|
|
28
|
|
00:02:46,000 --> 00:02:51,000
|
|
你甚至可以创建自己的自定义模板,应用于任何文章或页面。
|
|
You can even create your own custom template that can be applied to any post or page.
|
|
|
|
29
|
|
00:02:53,000 --> 00:03:00,492
|
|
当你创建一个新模板(这里指自定义模板)并为其命名后,
|
|
When you create a new template, in this case a custom template, and after you have named it,
|
|
|
|
30
|
|
00:03:00,492 --> 00:03:10,000
|
|
系统会询问你是否要选择一个样板,如果你想从空白开始,只需选择跳过。
|
|
you will be asked if you would like to select a pattern, and if you want to start blank, merely select Skip.
|
|
|
|
31
|
|
00:03:11,000 --> 00:03:14,000
|
|
接下来,我们如何编辑模板?
|
|
Next, how do we edit templates?
|
|
|
|
32
|
|
00:03:14,000 --> 00:03:20,810
|
|
选择相关模板后,你可以点击页面旁边边栏中的编辑图标,
|
|
After selecting the relevant template, you can click on the Edit icon in the sidebar next to Pages,
|
|
|
|
33
|
|
00:03:20,810 --> 00:03:25,000
|
|
或点击右侧模板屏幕上的编辑图标。
|
|
or on the Template screen on the right.
|
|
|
|
34
|
|
00:03:26,000 --> 00:03:31,000
|
|
一旦你的模板打开,你就可以开始编辑页眉和页脚模板部分。
|
|
Once your template opens up, you can start editing your header and footer template parts.
|
|
|
|
35
|
|
00:03:31,000 --> 00:03:34,000
|
|
让我们暂停片刻,思考一下。
|
|
Let's pause to reflect for a moment.
|
|
|
|
36
|
|
00:03:34,000 --> 00:03:40,000
|
|
当你编辑模板时,需要记住区分动态部分和静态部分。
|
|
When you edit a template, you need to remember to separate the dynamic parts and the static parts.
|
|
|
|
37
|
|
00:03:40,000 --> 00:03:46,000
|
|
动态部分是内容部分,它会为使用该模板的每个页面或文章而变化。
|
|
The dynamic part is the content part that will change for every page or post that uses the template.
|
|
|
|
38
|
|
00:03:46,000 --> 00:03:51,600
|
|
正如你在这个例子中看到的,你的页面或文章的内容将会显示在
|
|
And as you can see in this example, the content from your page or post will be displayed
|
|
|
|
39
|
|
00:03:51,600 --> 00:03:55,000
|
|
你模板中添加了文章内容区块的位置。
|
|
where the post content block has been added in your template.
|
|
|
|
40
|
|
00:03:55,000 --> 00:03:59,500
|
|
静态部分是模板中可重复使用的部分,它们保持不变,
|
|
The static parts are the reusable parts of the template that will stay the same,
|
|
|
|
41
|
|
00:03:59,500 --> 00:04:01,000
|
|
比如页眉和页脚。
|
|
like the header and the footer.
|
|
|
|
42
|
|
00:04:01,000 --> 00:04:05,000
|
|
因此,我们不会向模板添加任何内容。
|
|
We therefore don't add any content to the template.
|
|
|
|
43
|
|
00:04:06,000 --> 00:04:11,571
|
|
因此,站点编辑器明确区分了编辑页面内容与编辑其模板,
|
|
The site editor therefore makes a clear distinction between editing a page's content and its template,
|
|
|
|
44
|
|
00:04:11,571 --> 00:04:18,000
|
|
让你能更轻松地在两种模式间切换,并在合适的上下文中查看它们。
|
|
making it easier for you to switch between the two modes and view them in the appropriate context.
|
|
|
|
45
|
|
00:04:18,000 --> 00:04:21,000
|
|
让我们看看实际操作。
|
|
Let's see this in action.
|
|
|
|
46
|
|
00:04:21,000 --> 00:04:25,000
|
|
那么,我们继续并打开我们的一个页面。
|
|
So let's go ahead and open up one of our pages.
|
|
|
|
47
|
|
00:04:25,000 --> 00:04:29,000
|
|
在这个例子中,是我的示例页面。
|
|
And in this case, my sample page.
|
|
|
|
48
|
|
00:04:29,000 --> 00:04:34,000
|
|
一旦我们打开了页面,我们也可以继续并打开列表视图。
|
|
Once we open up our page, we can also go ahead and open up the list view.
|
|
|
|
49
|
|
00:04:35,000 --> 00:04:41,000
|
|
当我们选中文章内容区块时,我们会注意到我们添加的所有内容
|
|
And when we select the post content block, we will notice that all our content that we've added
|
|
|
|
50
|
|
00:04:41,000 --> 00:04:44,000
|
|
都已被添加到文章内容区块中。
|
|
has been added to the post content block.
|
|
|
|
51
|
|
00:04:44,000 --> 00:04:49,000
|
|
您也会在右侧的设置边栏中看到这一点。
|
|
You will also see this in the settings sidebar on the right.
|
|
|
|
52
|
|
00:04:49,000 --> 00:04:54,000
|
|
但如果我现在尝试编辑我的页眉和页脚,会发生什么?
|
|
But what will happen now if I try to edit my header and my footer?
|
|
|
|
53
|
|
00:04:54,000 --> 00:04:59,000
|
|
我们继续并点击页眉来尝试修改它。
|
|
Let's go ahead and click on the header to try and modify this.
|
|
|
|
54
|
|
00:04:59,000 --> 00:05:04,000
|
|
您会看到一条弹出的消息,上面写着“编辑您的模板以编辑此区块”。
|
|
You will see a message that pops up and it says edit your template to edit this block.
|
|
|
|
55
|
|
00:05:04,000 --> 00:05:08,000
|
|
我们的页脚也是如此。
|
|
And the same goes for our footer.
|
|
|
|
56
|
|
00:05:08,000 --> 00:05:16,000
|
|
如果我们尝试编辑页脚,系统会提示我们前往模板。
|
|
If we try and edit our footer, we will be prompted to make our way to the template.
|
|
|
|
57
|
|
00:05:16,000 --> 00:05:25,000
|
|
为此,我们可以点击右侧底部设置边栏中的“编辑模板”。
|
|
So to do this, we can click on edit template in the settings sidebar on the right at the bottom.
|
|
|
|
58
|
|
00:05:25,000 --> 00:05:29,000
|
|
这将带您进入已分配给相关页面的模板。
|
|
This will take you to the template that has been assigned to the relevant page.
|
|
|
|
59
|
|
00:05:29,000 --> 00:05:34,000
|
|
现在我们可以继续更新我们的页眉和页脚。
|
|
And now we can go ahead and update our header and our footer.
|
|
|
|
60
|
|
00:05:34,000 --> 00:05:39,000
|
|
我们会注意到文章内容区块只是一个占位符。
|
|
And we will notice that the post content block is only a placeholder.
|
|
|
|
61
|
|
00:05:39,000 --> 00:05:43,000
|
|
我们无法在此处添加任何内容。
|
|
We cannot add any content here.
|
|
|
|
62
|
|
00:05:43,000 --> 00:05:50,156
|
|
接下来,我将选择我的页脚,点击那三个垂直的点,
|
|
Next, I'm going to select my footer, click on the three vertical dots,
|
|
|
|
63
|
|
00:05:50,156 --> 00:05:57,000
|
|
然后用我现有的一个页脚模板部分替换这个页脚。
|
|
and then replace this footer with one of my existing footer template parts.
|
|
|
|
64
|
|
00:05:57,000 --> 00:06:00,385
|
|
完成后,我将点击保存。
|
|
And when I'm done, I'm going to click save.
|
|
|
|
65
|
|
00:06:00,385 --> 00:06:05,000
|
|
现在我已经更新了我的页面模板。
|
|
And now I have updated my page template.
|
|
|
|
66
|
|
00:06:05,000 --> 00:06:11,000
|
|
如果你想返回页面,请点击工具栏上的返回按钮。
|
|
If you would like to return to the page, click on back on your toolbar.
|
|
|
|
67
|
|
00:06:11,000 --> 00:06:15,000
|
|
这将带你回到页面,以便你可以修改你的内容。
|
|
And this will take you back to the page so that you can modify your content.
|
|
|
|
68
|
|
00:06:15,000 --> 00:06:19,000
|
|
当然,你也可以单独编辑你的模板。
|
|
And of course, you can edit your template separately.
|
|
|
|
69
|
|
00:06:19,000 --> 00:06:23,714
|
|
当我们回到侧边栏视图中的模板部分时,
|
|
When we make our way back to templates in the side view sidebar,
|
|
|
|
70
|
|
00:06:23,714 --> 00:06:30,000
|
|
我们会注意到在最底部,有一个管理所有模板的选项。
|
|
we will notice right at the bottom, there's an option to manage all templates.
|
|
|
|
71
|
|
00:06:30,000 --> 00:06:38,000
|
|
当你选择这个选项时,你将能够重命名和删除你创建的自定义模板。
|
|
And when you select this, you'll be able to rename and delete custom templates you have created.
|
|
|
|
72
|
|
00:06:38,000 --> 00:06:46,000
|
|
或者你可以清除你修改过的构建模板的自定义设置。
|
|
Or you can clear the customizations of building templates you have modified.
|
|
|
|
73
|
|
00:06:46,000 --> 00:06:51,062
|
|
在下一节中,我们将讨论为页面或文章分配不同的模板。
|
|
In the next section, we are going to discuss assigning a different template to a page or post.
|
|
|
|
74
|
|
00:06:51,062 --> 00:06:54,810
|
|
现在,我们正在我的示例页面的前端,
|
|
Now, at the moment, we are on the front end of my sample page,
|
|
|
|
75
|
|
00:06:54,810 --> 00:06:59,000
|
|
并且我们已经将此页面分配给了页面模板。
|
|
and we have assigned this page to the page template.
|
|
|
|
76
|
|
00:06:59,000 --> 00:07:05,000
|
|
我已经提前创建了一个带有新页眉和新页脚的自定义模板。
|
|
I've gone ahead and created a custom template with a new header and a new footer.
|
|
|
|
77
|
|
00:07:05,000 --> 00:07:10,645
|
|
要分配新的自定义模板,我们可以点击顶部的编辑页面,
|
|
To assign the new custom template, we can click on edit page at the top,
|
|
|
|
78
|
|
00:07:10,645 --> 00:07:19,000
|
|
或者我们可以前往仪表盘,打开页面,选择相关页面,在这个例子中就是示例页面。
|
|
or we can make our way to the dashboard, open up pages, select the relevant page, in this case, the sample page.
|
|
|
|
79
|
|
00:07:19,000 --> 00:07:23,475
|
|
然后,一旦我们打开页面,就会看到我们的内容,
|
|
And then once we open up the page, we will see our content,
|
|
|
|
80
|
|
00:07:23,475 --> 00:07:31,000
|
|
但当我们打开右侧的边栏设置时,会看到此页面已被指派给页面模板,即默认模板。
|
|
but when we open up our sidebar settings, on the right, we will see that this page has been assigned to the page template, the default template.
|
|
|
|
81
|
|
00:07:31,000 --> 00:07:34,214
|
|
如果你点击这个名称,
|
|
If you click on the name,
|
|
|
|
82
|
|
00:07:34,214 --> 00:07:40,000
|
|
你会注意到可以从这里添加一个新模板。
|
|
you will notice you are able to add a new template from here.
|
|
|
|
83
|
|
00:07:40,000 --> 00:07:43,000
|
|
你可以编辑已分配给此页面的模板。
|
|
You can edit the template assigned to the page.
|
|
|
|
84
|
|
00:07:43,000 --> 00:07:50,000
|
|
或者,如果你点击下拉菜单,可以选择或为此页面分配一个新模板。
|
|
Or if you click on the dropdown, you can select or assign a new template to this page.
|
|
|
|
85
|
|
00:07:50,000 --> 00:07:56,000
|
|
我将继续操作,选择我创建的自定义模板。
|
|
I'm going to go ahead and select the custom template which I have created.
|
|
|
|
86
|
|
00:07:56,000 --> 00:08:01,000
|
|
一旦完成,我就会更新。
|
|
And once I've done that, I will update.
|
|
|
|
87
|
|
00:08:01,000 --> 00:08:05,800
|
|
我们可以在新标签页中预览页面,
|
|
We can preview the page in a new tab,
|
|
|
|
88
|
|
00:08:05,800 --> 00:08:17,000
|
|
现在我们会看到,由于我为此页面分配了自定义模板,它有了新的页眉和页脚。
|
|
and now we will see that this page has a new header and a new footer due to the custom template which I have assigned to this page.
|
|
|
|
89
|
|
00:08:17,000 --> 00:08:24,000
|
|
最后,我们简要谈谈用于设置模板的页眉和页脚模板部分。
|
|
Lastly, let's briefly talk about header and footer template parts which we use to set up our templates.
|
|
|
|
90
|
|
00:08:24,000 --> 00:08:29,000
|
|
你可以直接在模板内编辑页眉或页脚模板部分。
|
|
You can edit a header or footer template part right within a template.
|
|
|
|
91
|
|
00:08:29,000 --> 00:08:33,565
|
|
在这个例子中,我正在编辑我的页眉模板部分,
|
|
In this example, I am editing my header template part,
|
|
|
|
92
|
|
00:08:33,565 --> 00:08:39,000
|
|
并将站点标题和站点标语区块堆叠在一个堆叠组区块中。
|
|
and I'm stacking my site title and my site tagline block together in a stacked group block.
|
|
|
|
93
|
|
00:08:39,000 --> 00:08:45,182
|
|
然后,我还会确保打开我的设置边栏,
|
|
Then I'll also make sure that I open up my settings sidebar,
|
|
|
|
94
|
|
00:08:45,182 --> 00:08:51,000
|
|
并移除这两个区块之间的一些间距。
|
|
and I will remove some spacing between the two blocks.
|
|
|
|
95
|
|
00:08:51,000 --> 00:08:56,000
|
|
当你选择一个页眉或页脚模板部分时,会看到一个写着“编辑”的选项。
|
|
When you select a header or footer template part, you will see an option that says edit.
|
|
|
|
96
|
|
00:08:56,000 --> 00:09:06,000
|
|
当你选择编辑时,就能在模板编辑模式下编辑模板部分,不受任何干扰。
|
|
When you select edit, you will be able to edit the template part in template editing mode without any distractions.
|
|
|
|
97
|
|
00:09:06,000 --> 00:09:14,000
|
|
另一个选项是前往站点视图边栏中的样板。
|
|
Another option is to make your way to patterns in your site view sidebar.
|
|
|
|
98
|
|
00:09:14,000 --> 00:09:17,810
|
|
当你选择样板时,可以滚动到底部,
|
|
When you select patterns, you can scroll to the bottom,
|
|
|
|
99
|
|
00:09:17,810 --> 00:09:24,000
|
|
在这里你可以查看和修改你的页眉、页脚和通用模板部分。
|
|
and here you are able to view and modify your header, footer and general template parts.
|
|
|
|
100
|
|
00:09:24,000 --> 00:09:28,735
|
|
要添加新的模板部分,请点击样板旁边的加号图标,
|
|
To add a new template part, click on the plus icon next to patterns
|
|
|
|
101
|
|
00:09:28,735 --> 00:09:31,000
|
|
然后选择创建模板部分。
|
|
and select create template part.
|
|
|
|
102
|
|
00:09:31,000 --> 00:09:35,000
|
|
你可以在通用、页眉和页脚模板部分之间进行选择。
|
|
You have an option between general, header and footer template parts.
|
|
|
|
103
|
|
00:09:35,000 --> 00:09:38,579
|
|
通用模板部分不绑定到任何特定区域,
|
|
General template parts are not tied to any particular area,
|
|
|
|
104
|
|
00:09:38,579 --> 00:09:43,000
|
|
并且记得为你的模板部分起一个描述性的名称。
|
|
and remember to give your template part a descriptive name.
|
|
|
|
105
|
|
00:09:43,000 --> 00:09:46,912
|
|
当你点击模板部分下方的三个水平圆点时,
|
|
When you click on the three horizontal dots below a template part,
|
|
|
|
106
|
|
00:09:46,912 --> 00:09:50,000
|
|
你将能够重命名、复制或删除它。
|
|
you will be able to rename, duplicate or delete it.
|
|
|
|
107
|
|
00:09:50,000 --> 00:09:53,143
|
|
当你选中该模板部分时,
|
|
And when you select the template part,
|
|
|
|
108
|
|
00:09:53,143 --> 00:10:00,000
|
|
你将能够在编辑模式下修改它,不受干扰,如前所示。
|
|
you will be able to modify it in editing mode without any distractions as shown before.
|
|
|
|
109
|
|
00:10:00,000 --> 00:10:03,000
|
|
我们希望您现在对模板的工作原理有了更好的理解。
|
|
We hope you now have a better understanding of how templates work.
|
|
|
|
110
|
|
00:10:03,000 --> 00:10:07,846
|
|
回顾一下,模板为内容的显示方式提供了结构,
|
|
To review, a template provides the structure for how your content is displayed,
|
|
|
|
111
|
|
00:10:07,846 --> 00:10:12,000
|
|
这通常通过页眉和页脚模板部分来实现。
|
|
and this is usually accomplished by header and footer template parts.
|
|
|
|
112
|
|
00:10:12,000 --> 00:10:16,000
|
|
并且模板可以分配给单个或多个页面。
|
|
And templates can be assigned to single or multiple pages.
|
|
|