8
n8n 中文网amn8n.com

批量删除 WordPress 中的文章和特色图片

中级

这是一个Marketing领域的自动化工作流,包含 14 个节点。主要使用 If, Filter, HttpRequest, ManualTrigger 等节点。 批量删除 WordPress 中的文章和特色图片

前置要求
  • 可能需要目标 API 的认证凭证

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "90f9a6ef38ec632934192a5de51518245cd649d4287258dedc9971969910cdb7"
  },
  "nodes": [
    {
      "id": "268a318e-a605-40dc-b28f-b16ff038399d",
      "name": "删除图片",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1700,
        420
      ],
      "parameters": {
        "url": "={{ $('Change your Domain here').item.json.wpUrl }}/wp-json/wp/v2/media/{{ $json.id }}",
        "method": "DELETE",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "force",
              "value": "true"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "97381d8a-bcba-4ea6-9fce-ab56a1588c83",
      "name": "获取图片",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1520,
        420
      ],
      "parameters": {
        "url": "={{ $('Change your Domain here').item.json.wpUrl }}/wp-json/wp/v2/media/{{ $('Filter').item.json.featured_media }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "07eb4f65-da06-413b-af1e-98504dc6050c",
      "name": "获取文章",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        600,
        580
      ],
      "parameters": {
        "url": "={{ $('Change your Domain here').item.json.wpUrl }}/wp-json/wp/v2/posts",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "status",
              "value": "pending"
            },
            {
              "name": "order",
              "value": "asc"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c18c430f-98d9-4e7c-9688-3cc2cfa5daa3",
      "name": "删除文章",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1880,
        600
      ],
      "parameters": {
        "url": "={{ $('Change your Domain here').item.json.wpUrl }}/wp-json/wp/v2/posts/{{ $('Filter').item.json.id }}",
        "method": "DELETE",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "force",
              "value": "true"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0d00aa0f-c030-489d-a7e1-744cdf0c1c7b",
      "name": "过滤器",
      "type": "n8n-nodes-base.filter",
      "position": [
        900,
        580
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "d099ced6-1ad2-4b37-a877-435b4f14537c",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "leftValue": "={{ $itemIndex }}",
              "rightValue": 1
            }
          ]
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "1f6f520f-35f1-4424-9cec-431175c42c0f",
      "name": "是否有图片",
      "type": "n8n-nodes-base.if",
      "position": [
        1200,
        580
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c1c1463c-be82-4ba0-9dd3-280dec6c2924",
              "operator": {
                "type": "number",
                "operation": "notEquals"
              },
              "leftValue": "={{ $('Filter').item.json.featured_media }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "36465680-6de2-484a-94e0-e7778b0ed7ef",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        240
      ],
      "parameters": {
        "width": 297.80842911877414,
        "height": 512.4904214559392,
        "content": "## 审批流程"
      },
      "typeVersion": 1
    },
    {
      "id": "3e200e7f-f14b-4897-a1b1-274256fa72a7",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        240
      ],
      "parameters": {
        "color": 4,
        "width": 317.5478927203068,
        "height": 512.4904214559392,
        "content": "## 路由器"
      },
      "typeVersion": 1
    },
    {
      "id": "9f017854-e445-409f-a465-5eef1c09e891",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1420,
        240
      ],
      "parameters": {
        "color": 6,
        "width": 696.8275862068976,
        "height": 512.4904214559392,
        "content": "## 这是关键步骤"
      },
      "typeVersion": 1
    },
    {
      "id": "b82386f4-f759-40ac-b89a-43815875882c",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        240
      ],
      "parameters": {
        "color": 5,
        "width": 297.80842911877414,
        "height": 512.4904214559392,
        "content": "## 触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "03d113e5-c1c0-4dab-ac64-c6a9388b9d91",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        500,
        240
      ],
      "parameters": {
        "color": 3,
        "width": 297.80842911877414,
        "height": 512.4904214559392,
        "content": "## 获取您的文章"
      },
      "typeVersion": 1
    },
    {
      "id": "72d4044c-8e62-43dc-8fd7-0b3fc9accbca",
      "name": "删除带图片的文章",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1880,
        420
      ],
      "parameters": {
        "url": "={{ $('Change your Domain here').item.json.wpUrl }}/wp-json/wp/v2/posts/{{ $('Filter').item.json.id }}",
        "method": "DELETE",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "force",
              "value": "true"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "3ccd76b6-8b6f-462e-bb29-a539b7a8e286",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2120,
        240
      ],
      "parameters": {
        "color": 7,
        "width": 286.52873563218395,
        "height": 512.490421455939,
        "content": "## 扩展功能"
      },
      "typeVersion": 1
    },
    {
      "id": "ac2c0f9a-ed6a-44cc-8ac7-0498187133e4",
      "name": "在此更改您的域名",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        300,
        580
      ],
      "parameters": {},
      "typeVersion": 1
    }
  ],
  "pinData": {
    "Change your Domain here": [
      {
        "wpUrl": "https://setyourwordpresshere.com"
      }
    ]
  },
  "connections": {
    "Filter": {
      "main": [
        [
          {
            "node": "Has Img",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Img": {
      "main": [
        [
          {
            "node": "get img",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "delete post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get img": {
      "main": [
        [
          {
            "node": "delete img",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get post": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "delete img": {
      "main": [
        [
          {
            "node": "delete post with img",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Change your Domain here": {
      "main": [
        [
          {
            "node": "get post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 营销

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量14
分类1
节点类型5
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流