WordPress帖子数据导出到Google Sheets(基于WP Rest API)
中级
这是一个Market Research领域的自动化工作流,包含 15 个节点。主要使用 Set, Code, Form, Merge, FormTrigger 等节点。 将带分类和标签的WordPress帖子导出到Google Sheets进行SEO审计
前置要求
- •可能需要目标 API 的认证凭证
- •Google Sheets API 凭证
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "XnO085uXrhMERPvb",
"meta": {
"instanceId": "2295c029f4cb86c8f849f9c87dade323734dc279619eb9e2704f8473c381e4d1",
"templateCredsSetupCompleted": true
},
"name": "WordPress 帖子数据导出到 Google Sheets(基于 WP Rest API)",
"tags": [],
"nodes": [
{
"id": "bfc25242-766f-4b7d-ab23-a0829de1fe83",
"name": "表单提交时",
"type": "n8n-nodes-base.formTrigger",
"position": [
-1120,
-320
],
"webhookId": "57b1b81e-feae-464e-9459-04b0e3efcaa1",
"parameters": {
"options": {},
"formTitle": "WP SEO Audit",
"formFields": {
"values": [
{
"fieldLabel": "URL",
"placeholder": "http://yourdomain.com",
"requiredField": true
},
{
"fieldType": "number",
"fieldLabel": "Post limit",
"placeholder": "Default =10"
}
]
}
},
"typeVersion": 2.3
},
{
"id": "3a5f6f97-c79a-4fed-b32a-fe7695e569f1",
"name": "获取帖子",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueErrorOutput",
"position": [
-400,
-128
],
"parameters": {
"url": "={{ $json.URL }}/wp-json/wp/v2/posts?per_page={{ $json['Post limit'] }}",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "2201ba9e-40b8-4bcc-988c-e8dce2578dda",
"name": "获取分类",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueErrorOutput",
"position": [
-400,
-320
],
"parameters": {
"url": "={{ $('On form submission').item.json.URL }}/wp-json/wp/v2/categories?per_page={{ $json.per_page }}",
"options": {},
"sendBody": true,
"bodyParameters": {
"parameters": [
{}
]
}
},
"typeVersion": 4.2
},
{
"id": "f6c0f099-2c27-45df-91b3-0fd1ea15d165",
"name": "获取标签",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueErrorOutput",
"position": [
-400,
-512
],
"parameters": {
"url": "={{ $('On form submission').item.json.URL }}/wp-json/wp/v2/tags?per_page={{ $json.per_page }}",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "6a924b56-3613-4b7f-a7c8-819bbe38387b",
"name": "合并",
"type": "n8n-nodes-base.merge",
"position": [
16,
-352
],
"parameters": {
"numberInputs": 3
},
"notesInFlow": false,
"typeVersion": 3.2
},
{
"id": "bc6731ac-f1aa-4594-a1a6-98275d976ea3",
"name": "WP API 错误",
"type": "n8n-nodes-base.form",
"position": [
-48,
-928
],
"webhookId": "ee9fe2bd-db09-469a-b3b1-cd335e4e6daf",
"parameters": {
"options": {},
"operation": "completion",
"completionTitle": "WordPress API Error",
"completionMessage": "Please check if your WP-Api is enabled"
},
"typeVersion": 2.3
},
{
"id": "46d785e4-fc5f-49ba-8aa6-ee6436621131",
"name": "为帖子分配标签和分类名称",
"type": "n8n-nodes-base.code",
"position": [
224,
-336
],
"parameters": {
"jsCode": "const tagItems = $items('Get Tags'); // [{ json: { id, name, ... }}, ...]\nconst categoryItems = $items('Get Categories'); // [{ json: { id, name, ... }}, ...]\nconst postItems = $items('Get Posts'); // [{ json: { categories: [ids], tags: [ids], ... }}, ...]\n\n// Build lookup maps\nconst tagsById = Object.fromEntries(\n tagItems\n .filter(i => i?.json?.id != null && i?.json?.name != null)\n .map(i => [String(i.json.id), i.json.name])\n);\n\nconst categoriesById = Object.fromEntries(\n categoryItems\n .filter(i => i?.json?.id != null && i?.json?.name != null)\n .map(i => [String(i.json.id), i.json.name])\n);\n\n// Helper: normalize a field that might be number | string | array into an array of strings\nconst toIdArray = (val) => {\n if (val == null) return [];\n if (Array.isArray(val)) return val.map(v => String(v));\n return [String(val)];\n};\n\n// Enrich posts with names instead of IDs\nconst out = postItems.map(item => {\n const post = item.json;\n\n const categoryIds = toIdArray(post.categories);\n const tagIds = toIdArray(post.tags);\n\n const categoryNames = categoryIds\n .map(id => categoriesById[id])\n .filter(Boolean);\n\n const tagNames = tagIds\n .map(id => tagsById[id])\n .filter(Boolean);\n\n return {\n json: {\n ...post,\n categoryNames,\n tagNames,\n },\n // keep binary if present\n binary: item.binary,\n };\n});\n\nreturn out;"
},
"typeVersion": 2
},
{
"id": "989f3e60-1a1b-454c-b5f8-cdd27bf5c379",
"name": "将带有标签、分类的帖子添加到 Google Sheet",
"type": "n8n-nodes-base.googleSheets",
"position": [
480,
-336
],
"parameters": {
"columns": {
"value": {
"URL": "={{ $json.link }}",
"Tags": "={{ $json.tagNames }}",
"Title": "={{ $json.title.rendered }}",
"Categories": "={{ $json.categoryNames }}"
},
"schema": [
{
"id": "URL",
"type": "string",
"display": true,
"required": false,
"displayName": "URL",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Title",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Title",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Categories",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Categories",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Tags",
"type": "string",
"display": true,
"required": false,
"displayName": "Tags",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nZ3WHn_QedbuNYlFVfPildBZETNYYJFT0yYFIgJy2Mg/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1nZ3WHn_QedbuNYlFVfPildBZETNYYJFT0yYFIgJy2Mg",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nZ3WHn_QedbuNYlFVfPildBZETNYYJFT0yYFIgJy2Mg/edit?usp=drivesdk",
"cachedResultName": "[WP]"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "sgj6aGeryqEVmS3h",
"name": "GSheets - Piotr.Sikora.Ck@gmail.com"
}
},
"typeVersion": 4.7
},
{
"id": "88750e8c-ad3c-4f40-b3f5-83618faa5de4",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
400,
-640
],
"parameters": {
"color": 4,
"height": 496,
"content": "## 将带有标签、分类的帖子添加到 Google Sheet"
},
"typeVersion": 1
},
{
"id": "ed1593aa-3c25-42d4-a8cc-020843039197",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-112,
-1072
],
"parameters": {
"color": 3,
"height": 304,
"content": "## WP API 错误"
},
"typeVersion": 1
},
{
"id": "f23af13c-7b4d-46b4-af31-f33726fd8356",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-480,
-928
],
"parameters": {
"color": 5,
"width": 256,
"height": 960,
"content": "## 获取 API 数据"
},
"typeVersion": 1
},
{
"id": "06d3d9a1-40bc-43e3-82a4-8bf08e640a9a",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
144,
-640
],
"parameters": {
"color": 6,
"height": 496,
"content": "## 附加分类和标签名称"
},
"typeVersion": 1
},
{
"id": "c51ef4bd-2234-486b-b0f1-2d40f0d00e00",
"name": "表单",
"type": "n8n-nodes-base.form",
"position": [
688,
-336
],
"webhookId": "32930177-d74b-4ab5-98b6-7726b70811f5",
"parameters": {
"options": {},
"operation": "completion",
"completionTitle": "List created",
"completionMessage": "Please check linked document to see details"
},
"typeVersion": 2.3
},
{
"id": "b5e7141e-b922-496f-afd7-1c75a29dc408",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-848,
-656
],
"parameters": {
"color": 7,
"height": 368,
"content": "## 配置每页数量"
},
"typeVersion": 1
},
{
"id": "7a062203-6a2e-4521-a98d-f1435f52ad17",
"name": "配置",
"type": "n8n-nodes-base.set",
"position": [
-784,
-448
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "39de8718-83b1-4060-9dc9-23b1a0a20857",
"name": "per_page",
"type": "number",
"value": 100
}
]
}
},
"typeVersion": 3.4
}
],
"active": false,
"pinData": {
"On form submission": [
{
"json": {
"URL": "http://juttle.app",
"formMode": "test",
"Post limit": 1,
"submittedAt": "2025-10-22T10:15:02.313+02:00"
}
}
]
},
"settings": {
"executionOrder": "v1"
},
"versionId": "91e580eb-4b6f-45ea-a1fc-68998aa694db",
"connections": {
"Merge": {
"main": [
[
{
"node": "Assign tags and categories names to posts",
"type": "main",
"index": 0
}
]
]
},
"Config": {
"main": [
[
{
"node": "Get Tags",
"type": "main",
"index": 0
},
{
"node": "Get Categories",
"type": "main",
"index": 0
}
]
]
},
"Get Tags": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
],
[
{
"node": "WP API Error",
"type": "main",
"index": 0
}
]
]
},
"Get Posts": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 2
}
],
[
{
"node": "WP API Error",
"type": "main",
"index": 0
}
]
]
},
"Get Categories": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
],
[
{
"node": "WP API Error",
"type": "main",
"index": 0
}
]
]
},
"On form submission": {
"main": [
[
{
"node": "Get Posts",
"type": "main",
"index": 0
},
{
"node": "Config",
"type": "main",
"index": 0
}
]
]
},
"Assign tags and categories names to posts": {
"main": [
[
{
"node": "Add posts, with tags, categories to Google Sheet",
"type": "main",
"index": 0
}
]
]
},
"Add posts, with tags, categories to Google Sheet": {
"main": [
[
{
"node": "Form",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 市场调研
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用参与度评分和Google Sheets分析YouTube视频的病毒内容
使用参与度评分和Google Sheets分析YouTube视频的病毒内容
Set
Code
Wait
+6
22 节点Akash Kankariya
市场调研
[astro/nextjs] 为文章/帖子分配类别/标签
使用OpenAI GPT-4、GitHub和Google Sheets为Astro/Next.js博客文章自动分类
Code
Form
Merge
+11
29 节点Piotr Sikora
内容创作
[LI] - 搜索个人资料
使用SerpAPI谷歌搜索和表格收集LinkedIn个人资料
Set
Code
Form
+7
14 节点Piotr Sikora
潜在客户开发
选题捕手模板
使用Gemini分析Reddit、YouTube和X生成内容策略报告
If
Set
Code
+14
34 节点Sheryl
市场调研
YouTube 趋势发现器
YouTube 趋势发现助手
If
Set
Code
+8
17 节点Rakin Jakaria
市场调研
CSV到HubSpot上传器(动态字段映射与Google Sheets集成)
具有动态字段映射和Google Sheets集成的CSV到HubSpot上传器
If
Set
Code
+10
36 节点PollupAI
人工智能