a
anipage.io
免费开始
Glossary

Template Part — WordPress可复用模板部件详解

模板部件是WordPress区块主题中的可复用组件,如页眉和页脚。了解其工作原理及与经典PHP模板的区别。

Definition

A template part is a saved block snippet in a WordPress block theme that can be used across multiple templates. The most common use case: header and footer as template parts appearing on all pages. Since Full Site Editing (WordPress 5.9), template parts can be edited directly in the editor — no PHP knowledge required.

Template parts vs. classic PHP templates

In classic WordPress themes, the header is defined in `header.php` and the footer in `footer.php` — editable only by code. In block themes, header and footer are template parts: visually editable in the Full Site Editor, stored as HTML files with Gutenberg block markup in the `/parts/` folder.

Creating and editing template parts

In the Full Site Editor (Appearance → Editor), existing template parts can be edited or new ones created. New parts are saved as HTML files in the theme. Template parts are included in templates via `<!-- wp:template-part {"slug":"header"} /-->`.

Template parts and anipage.io

anipage.io generates complete page content as Gutenberg block markup — including header- and footer-like sections. The export contains the page content (without theme template parts), which can be imported into existing WordPress themes without overwriting existing template parts.

Frequently Asked Questions

What is a template part in WordPress?
A template part is a reusable block snippet (e.g. header or footer) edited in block themes via the Full Site Editor, used across multiple page templates.
Can I edit template parts without coding?
Yes. In the Full Site Editor (WordPress 5.9+), template parts can be edited visually — no PHP or coding knowledge required.
Do I need a block theme for template parts?
Yes. Template parts are a feature of block themes. Classic themes use PHP template files instead of WordPress blocks.

准备好几分钟内创建 WordPress 页面了吗?

免费开始,每月3次生成。无需信用卡。无需承诺。随时取消。

立即免费开始

Related Terms

Related Articles