elementor-content
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseElementor Content
Elementor 内容
Directly read, create, modify, and restructure Elementor page builder content by working with the underlying JSON data — either in exported template files or in the WordPress database via WP-CLI.
.json通过处理底层JSON数据,直接读取、创建、修改和重构Elementor页面构建器内容——既可以处理导出的模板文件,也可以通过WP-CLI操作WordPress数据库中的内容。
.jsonWhen to Use
适用场景
- Creating or editing Elementor page/template content
- Modifying widget settings (text, images, styles, links)
- Restructuring page layouts (moving sections, adding containers)
- Bulk-updating content across multiple Elementor pages
- Importing/exporting Elementor templates
- Building new Elementor pages from scratch
- Creating Theme Builder templates (header, footer, single, archive) programmatically
- 创建或编辑Elementor页面/模板内容
- 修改组件设置(文本、图片、样式、链接)
- 重构页面布局(移动区块、添加容器)
- 批量更新多个Elementor页面的内容
- 导入/导出Elementor模板
- 从零开始构建新的Elementor页面
- 通过代码创建主题构建器模板(页眉、页脚、单页、归档)
Operational Modes
操作模式
Mode 1: JSON Template Files
模式1:JSON模板文件
Work directly with files exported from Elementor (Library → Export Template). Read, edit, and write the file. Import back via Elementor UI or WP-CLI.
.json直接处理从Elementor导出的文件(库→导出模板)。读取、编辑并保存文件后,可通过Elementor界面或WP-CLI重新导入。
.jsonMode 2: WP-CLI Database Operations
模式2:WP-CLI数据库操作
Read/write the post meta key in WordPress. Requires WP-CLI access and a running WordPress installation. See .
_elementor_datareferences/wp-cli-operations.md读取或写入WordPress中的文章元键。需要具备WP-CLI访问权限,且WordPress实例处于运行状态。详情请查阅。
_elementor_datareferences/wp-cli-operations.mdCore Workflow
核心工作流
- Identify mode — JSON file on disk, or live WordPress database?
- Read the content — parse the JSON file or fetch via
wp post meta get - Understand the tree — Elementor content is a nested array of elements (see )
references/element-structure.md - Locate target — find the element to modify by walking the tree; match on ,
widgetTypecontent, orsettingsid - Modify — change settings, add/remove/reorder elements
- Validate — run the validation checklist below before writing
- Write — save the JSON file or update via
wp post meta update - Flush cache — if using WP-CLI, run to regenerate stylesheets
wp elementor flush-css
- 确定操作模式——是处理本地JSON文件,还是在线WordPress数据库?
- 读取内容——解析JSON文件,或通过命令获取数据
wp post meta get - 理解层级结构——Elementor内容是元素的嵌套数组(详情请查阅)
references/element-structure.md - 定位目标元素——遍历层级结构找到需要修改的元素;可通过、
widgetType内容或settings进行匹配id - 修改内容——更改设置、添加/删除/重新排序元素
- 验证——在保存前完成下方的验证清单
- 保存内容——保存JSON文件,或通过命令更新数据库
wp post meta update - 清除缓存——如果使用WP-CLI,执行命令重新生成样式表
wp elementor flush-css
Reference Guides
参考指南
| Topic | File | Load when... |
|---|---|---|
| JSON structure & hierarchy | | You need to understand the data format, nesting rules, or settings patterns |
| Widget types & settings | | You need to create a widget or modify widget-specific settings |
| WP-CLI operations | | You're working with a live WordPress database (not a JSON file) |
| Theme Builder templates | | You're creating header, footer, single, or archive templates programmatically |
| 主题 | 文件 | 何时查阅 |
|---|---|---|
| JSON结构与层级 | | 当你需要理解数据格式、嵌套规则或设置模式时 |
| 组件类型与设置 | | 当你需要创建组件或修改组件专属设置时 |
| WP-CLI操作 | | 当你操作的是在线WordPress数据库(而非JSON文件)时 |
| 主题构建器模板 | | 当你需要通过代码创建页眉、页脚、单页或归档模板时 |
Quick Reference: Common Operations
快速参考:常见操作
Change a heading:
Find the element with , update .
"widgetType": "heading"settings.titleAdd a button to a container:
Create a new element with , , generate a unique , set and , and append to the parent container's array.
"elType": "widget""widgetType": "button"idsettings.textsettings.linkelementsRestructure layout:
Move elements between parent containers by cutting from one array and pasting into another. Ensure no element appears in two places.
elementsCreate a new page:
Build the full JSON tree: outer container(s) → inner containers/widgets. Wrap in template format if exporting, or write directly to via WP-CLI.
_elementor_dataCreate a Theme Builder template:
Requires post meta (, ), taxonomy term (), AND registration in the option. See for the full checklist — missing any step will silently fail.
_elementor_template_type_elementor_conditionselementor_library_typeelementor_pro_theme_builder_conditionsreferences/theme-builder-templates.mdChange styling:
Modify the relevant settings key on the element. Responsive variants use and suffixes. Dimensions use objects.
_tablet_mobile{top, right, bottom, left, unit, isLinked}修改标题:
找到的元素,更新的值。
"widgetType": "heading"settings.title为容器添加按钮:
创建一个新元素,设置、,生成唯一的,设置和,然后将其添加到父容器的数组中。
"elType": "widget""widgetType": "button"idsettings.textsettings.linkelements重构布局:
通过将元素从一个数组剪切并粘贴到另一个数组,在父容器之间移动元素。确保元素不会同时出现在两个位置。
elements创建新页面:
构建完整的JSON层级结构:外层容器→内层容器/组件。如果是导出模板,需要包裹模板结构;或通过WP-CLI直接写入。
_elementor_data创建主题构建器模板:
需要设置文章元数据(、)、分类法术语(),并在选项中注册。完整步骤请查阅——遗漏任何步骤都会导致静默失败。
_elementor_template_type_elementor_conditionselementor_library_typeelementor_pro_theme_builder_conditionsreferences/theme-builder-templates.md修改样式:
修改元素对应的设置键。响应式变体使用和后缀。尺寸设置使用对象格式。
_tablet_mobile{top, right, bottom, left, unit, isLinked}Element ID Generation
元素ID生成规则
Every element requires a unique — an 8-character lowercase hexadecimal string (e.g., ). Generate randomly; ensure no duplicates within the document.
id"3f2a1b7c"每个元素都需要唯一的——一个8位小写十六进制字符串(例如:)。随机生成即可,但要确保在当前文档中无重复。
id"3f2a1b7c"Constraints
约束条件
- MUST preserve valid JSON at all times
- MUST keep every element's unique within the document
id - MUST maintain correct nesting: containers hold containers or widgets; widgets have (empty)
"elements": [] - MUST include on every element
elType - MUST include on every widget element
widgetType - MUST NOT place widgets directly inside the root array — they must be inside a container (or legacy section → column)
- MUST NOT leave orphaned references (e.g., removing a container but leaving its children elsewhere)
- MUST flush CSS cache after database writes ()
wp elementor flush-css
- 必须始终保证JSON格式有效
- 必须确保文档内每个元素的唯一
id - 必须维持正确的嵌套结构:容器可包含容器或组件;组件的必须为空数组
"elements": [] - 必须为每个元素设置
elType - 必须为每个组件元素设置
widgetType - 禁止将组件直接放在根数组中——必须包裹在容器(或旧版的区块→列)内
- 禁止留下孤立引用(例如:删除容器但将其子元素留在其他位置)
- 必须在数据库写入后清除CSS缓存(执行命令)
wp elementor flush-css
Validation Checklist
验证清单
Before writing the modified content:
- Valid JSON (parseable without errors)
- All values are unique 8-char hex strings
id - Every element has set (
elType,"container","widget", or"section")"column" - Every widget has set to a valid type
widgetType - Widgets have (empty array, never omitted)
"elements": [] - No widgets at root level — all wrapped in containers
- Settings values use correct format (dimensions, URLs, media objects)
- Template wrapper (if applicable) has ,
type,version,titlecontent
在保存修改后的内容前,请检查以下项:
- JSON格式有效(可正常解析无错误)
- 所有值都是唯一的8位十六进制字符串
id - 每个元素都已设置(可选值:
elType、"container"、"widget"或"section")"column" - 每个组件都已设置有效的
widgetType - 组件的为空白数组(绝对不能省略)
"elements": [] - 根层级无组件——所有组件都已包裹在容器内
- 设置值使用正确格式(尺寸、URL、媒体对象等)
- 模板包裹结构(如果适用)包含、
type、version、title字段content