elementor-content

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Elementor Content

Elementor 内容

Directly read, create, modify, and restructure Elementor page builder content by working with the underlying JSON data — either in exported
.json
template files or in the WordPress database via WP-CLI.
通过处理底层JSON数据,直接读取、创建、修改和重构Elementor页面构建器内容——既可以处理导出的
.json
模板文件,也可以通过WP-CLI操作WordPress数据库中的内容。

When 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
.json
files exported from Elementor (Library → Export Template). Read, edit, and write the file. Import back via Elementor UI or WP-CLI.
直接处理从Elementor导出的
.json
文件(库→导出模板)。读取、编辑并保存文件后,可通过Elementor界面或WP-CLI重新导入。

Mode 2: WP-CLI Database Operations

模式2:WP-CLI数据库操作

Read/write the
_elementor_data
post meta key in WordPress. Requires WP-CLI access and a running WordPress installation. See
references/wp-cli-operations.md
.
读取或写入WordPress中的
_elementor_data
文章元键。需要具备WP-CLI访问权限,且WordPress实例处于运行状态。详情请查阅
references/wp-cli-operations.md

Core Workflow

核心工作流

  1. Identify mode — JSON file on disk, or live WordPress database?
  2. Read the content — parse the JSON file or fetch via
    wp post meta get
  3. Understand the tree — Elementor content is a nested array of elements (see
    references/element-structure.md
    )
  4. Locate target — find the element to modify by walking the tree; match on
    widgetType
    ,
    settings
    content, or
    id
  5. Modify — change settings, add/remove/reorder elements
  6. Validate — run the validation checklist below before writing
  7. Write — save the JSON file or update via
    wp post meta update
  8. Flush cache — if using WP-CLI, run
    wp elementor flush-css
    to regenerate stylesheets
  1. 确定操作模式——是处理本地JSON文件,还是在线WordPress数据库?
  2. 读取内容——解析JSON文件,或通过
    wp post meta get
    命令获取数据
  3. 理解层级结构——Elementor内容是元素的嵌套数组(详情请查阅
    references/element-structure.md
  4. 定位目标元素——遍历层级结构找到需要修改的元素;可通过
    widgetType
    settings
    内容或
    id
    进行匹配
  5. 修改内容——更改设置、添加/删除/重新排序元素
  6. 验证——在保存前完成下方的验证清单
  7. 保存内容——保存JSON文件,或通过
    wp post meta update
    命令更新数据库
  8. 清除缓存——如果使用WP-CLI,执行
    wp elementor flush-css
    命令重新生成样式表

Reference Guides

参考指南

TopicFileLoad when...
JSON structure & hierarchy
references/element-structure.md
You need to understand the data format, nesting rules, or settings patterns
Widget types & settings
references/widget-catalog.md
You need to create a widget or modify widget-specific settings
WP-CLI operations
references/wp-cli-operations.md
You're working with a live WordPress database (not a JSON file)
Theme Builder templates
references/theme-builder-templates.md
You're creating header, footer, single, or archive templates programmatically
主题文件何时查阅
JSON结构与层级
references/element-structure.md
当你需要理解数据格式、嵌套规则或设置模式时
组件类型与设置
references/widget-catalog.md
当你需要创建组件或修改组件专属设置时
WP-CLI操作
references/wp-cli-operations.md
当你操作的是在线WordPress数据库(而非JSON文件)时
主题构建器模板
references/theme-builder-templates.md
当你需要通过代码创建页眉、页脚、单页或归档模板时

Quick Reference: Common Operations

快速参考:常见操作

Change a heading: Find the element with
"widgetType": "heading"
, update
settings.title
.
Add a button to a container: Create a new element with
"elType": "widget"
,
"widgetType": "button"
, generate a unique
id
, set
settings.text
and
settings.link
, and append to the parent container's
elements
array.
Restructure layout: Move elements between parent containers by cutting from one
elements
array and pasting into another. Ensure no element appears in two places.
Create a new page: Build the full JSON tree: outer container(s) → inner containers/widgets. Wrap in template format if exporting, or write directly to
_elementor_data
via WP-CLI.
Create a Theme Builder template: Requires post meta (
_elementor_template_type
,
_elementor_conditions
), taxonomy term (
elementor_library_type
), AND registration in the
elementor_pro_theme_builder_conditions
option. See
references/theme-builder-templates.md
for the full checklist — missing any step will silently fail.
Change styling: Modify the relevant settings key on the element. Responsive variants use
_tablet
and
_mobile
suffixes. Dimensions use
{top, right, bottom, left, unit, isLinked}
objects.
修改标题: 找到
"widgetType": "heading"
的元素,更新
settings.title
的值。
为容器添加按钮: 创建一个新元素,设置
"elType": "widget"
"widgetType": "button"
,生成唯一的
id
,设置
settings.text
settings.link
,然后将其添加到父容器的
elements
数组中。
重构布局: 通过将元素从一个
elements
数组剪切并粘贴到另一个数组,在父容器之间移动元素。确保元素不会同时出现在两个位置。
创建新页面: 构建完整的JSON层级结构:外层容器→内层容器/组件。如果是导出模板,需要包裹模板结构;或通过WP-CLI直接写入
_elementor_data
创建主题构建器模板: 需要设置文章元数据(
_elementor_template_type
_elementor_conditions
)、分类法术语(
elementor_library_type
),并在
elementor_pro_theme_builder_conditions
选项中注册。完整步骤请查阅
references/theme-builder-templates.md
——遗漏任何步骤都会导致静默失败。
修改样式: 修改元素对应的设置键。响应式变体使用
_tablet
_mobile
后缀。尺寸设置使用
{top, right, bottom, left, unit, isLinked}
对象格式。

Element ID Generation

元素ID生成规则

Every element requires a unique
id
— an 8-character lowercase hexadecimal string (e.g.,
"3f2a1b7c"
). Generate randomly; ensure no duplicates within the document.
每个元素都需要唯一的
id
——一个8位小写十六进制字符串(例如:
"3f2a1b7c"
)。随机生成即可,但要确保在当前文档中无重复。

Constraints

约束条件

  • MUST preserve valid JSON at all times
  • MUST keep every element's
    id
    unique within the document
  • MUST maintain correct nesting: containers hold containers or widgets; widgets have
    "elements": []
    (empty)
  • MUST include
    elType
    on every element
  • MUST include
    widgetType
    on every widget element
  • 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
    id
    values are unique 8-char hex strings
  • Every element has
    elType
    set (
    "container"
    ,
    "widget"
    ,
    "section"
    , or
    "column"
    )
  • Every widget has
    widgetType
    set to a valid type
  • Widgets have
    "elements": []
    (empty array, never omitted)
  • 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
    ,
    title
    ,
    content
在保存修改后的内容前,请检查以下项:
  • JSON格式有效(可正常解析无错误)
  • 所有
    id
    值都是唯一的8位十六进制字符串
  • 每个元素都已设置
    elType
    (可选值:
    "container"
    "widget"
    "section"
    "column"
  • 每个组件都已设置有效的
    widgetType
  • 组件的
    "elements": []
    为空白数组(绝对不能省略)
  • 根层级无组件——所有组件都已包裹在容器内
  • 设置值使用正确格式(尺寸、URL、媒体对象等)
  • 模板包裹结构(如果适用)包含
    type
    version
    title
    content
    字段