Can't read HTML from WordPress

Describe the problem/error/question

I’m trying to build an automation that will automatically split up and re-format posts from WP to social media, starting with twitter. There’s a lot of junk values in the post from Wordpress I can ignore but I was hoping to avoid have to write a ton of regex nodes that cuts out each property.

I have a WordPress plugin that fires webhooks on post creation/editing. I use N8N to receive the webhook (which includes the post content) and then I dragged the post content property over. However, the HTML5 node throws an error (below). I also tried getting the post with the built-in wordpress block and rendering the text from there but it also didn’t work with the same error. Why can’t it extract the information?

What is the error message (if any)?

Please share your workflow

Information on your n8n setup

  • n8n version: 1.26
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker/Cloudron
  • Operating system: Ubuntu

Hey @ianhyzy,

The error seems to suggest that the property you are using doesn’t exist, Can you share the JSON input you are using so we can test this?

[
  {
    "headers": {
      "host": "n8n.ian.gay",
      "x-real-ip": "172.18.18.207",
      "x-forwarded-for": "172.18.18.207",
      "x-forwarded-host": "n8n.ian.gay",
      "x-forwarded-port": "443",
      "x-forwarded-proto": "https",
      "x-forwarded-ssl": "on",
      "connection": "close",
      "content-length": "2721",
      "user-agent": "WP Webhooks/3.3.2 Trigger (WordPress/6.4.3)",
      "accept": "*/*",
      "accept-encoding": "deflate, gzip, br, zstd",
      "content-type": "application/json; charset=UTF-8",
      "x-wp-webhook-source": "https://ian.gay/",
      "x-wp-webhook-name": "post_update",
      "x-wp-webhook-url-name": "test-update"
    },
    "params": {},
    "query": {},
    "body": {
      "post_id": 459,
      "post": {
        "ID": 459,
        "post_author": "1",
        "post_date": "2024-02-08 16:45:52",
        "post_date_gmt": "2024-02-08 22:45:52",
        "post_content": "<!-- wp:paragraph -->\n<p>Body text</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:image {\"id\":460,\"sizeSlug\":\"large\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-block-image size-large\"><img src=\"https://ian.gay/wp-content/uploads/Unknown-1024x1024.jpeg\" alt=\"\" class=\"wp-image-460\"/></figure>\n<!-- /wp:image -->\n\n<!-- wp:paragraph -->\n<p>text after image</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:heading -->\n<h2 class=\"wp-block-heading\" id=\"h2-header\">h2 header</h2>\n<!-- /wp:heading -->",
        "post_title": "Test post",
        "post_excerpt": "",
        "post_status": "publish",
        "comment_status": "open",
        "ping_status": "closed",
        "post_password": "",
        "post_name": "test-post",
        "to_ping": "",
        "pinged": "",
        "post_modified": "2024-02-08 16:59:31",
        "post_modified_gmt": "2024-02-08 22:59:31",
        "post_content_filtered": "",
        "post_parent": 0,
        "guid": "https://ian.gay/?p=459",
        "menu_order": 0,
        "post_type": "post",
        "post_mime_type": "",
        "comment_count": "0",
        "filter": "raw"
      },
      "post_meta": {
        "_edit_lock": [
          "1707433169:1"
        ],
        "_edit_last": [
          "1"
        ],
        "_yoast_wpseo_primary_category": [
          ""
        ],
        "_yoast_wpseo_estimated-reading-time-minutes": [
          "1"
        ],
        "_yoast_wpseo_wordproof_timestamp": [
          ""
        ],
        "_encloseme": [
          "1"
        ]
      },
      "post_before": {
        "ID": 459,
        "post_author": "1",
        "post_date": "2024-02-08 16:45:52",
        "post_date_gmt": "2024-02-08 22:45:52",
        "post_content": "<!-- wp:paragraph -->\n<p>Body text</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:image {\"id\":460,\"sizeSlug\":\"large\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-block-image size-large\"><img src=\"https://ian.gay/wp-content/uploads/Unknown-1024x1024.jpeg\" alt=\"\" class=\"wp-image-460\"/></figure>\n<!-- /wp:image -->\n\n<!-- wp:paragraph -->\n<p>text after image</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:heading -->\n<h2 class=\"wp-block-heading\" id=\"h2-header\">h2 header</h2>\n<!-- /wp:heading -->",
        "post_title": "Test post",
        "post_excerpt": "",
        "post_status": "publish",
        "comment_status": "open",
        "ping_status": "closed",
        "post_password": "",
        "post_name": "test-post",
        "to_ping": "",
        "pinged": "",
        "post_modified": "2024-02-08 16:46:24",
        "post_modified_gmt": "2024-02-08 22:46:24",
        "post_content_filtered": "",
        "post_parent": 0,
        "guid": "https://ian.gay/?p=459",
        "menu_order": 0,
        "post_type": "post",
        "post_mime_type": "",
        "comment_count": "0",
        "filter": "raw"
      },
      "post_thumbnail": false,
      "post_permalink": "https://ian.gay/test-post/",
      "taxonomies": {
        "category": {
          "uncategorized": {
            "term_id": 1,
            "name": "Uncategorized",
            "slug": "uncategorized",
            "term_group": 0,
            "term_taxonomy_id": 1,
            "taxonomy": "category",
            "description": "",
            "parent": 0,
            "count": 3,
            "filter": "raw"
          }
        }
      }
    }
  }
]

Hey @ianhyzy,

It looks like the JSON isn’t complete.

I just grabbed the top snippet initially, I just updated the post with the full JSON from the node

Hey @ianhyzy,

Looks like you might have found a bug there, The option looks right but we are not correctly picking it up. As a quick workaround though the below will get you up and running.

thanks for responding - I still get ERROR: extractionValues.values is not iterable when trying to select the body property using your example flow

Hey @ianhyzy,

Ah I see what happened, I changed the node version and it caused some issues, the below which will extract the h2 text.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.