Wordpress Create Post with Mulitple Tag IDS issue - Solved

Describe the problem/error/question

Hey folks looking for some help with wordpress tags ids. I am getting new Tag Names from Airtable> and creating the WP IDs for these if they dont exist. Now for the life of me I can not get the create WP Post to ADD all the new tag IDs to a single post. the Wordpress create post is creating multiple posts each with 1 of the tag ids! Ive spent a very long time and tried everything I can think of - can anyone help thanks

What am i missing? AI overlords have not helped

What is the error message (if any)?

Wordpress is creating Multiple posts - 1 post for each TAG ID but i need 1 WP Post with aLL the tag ids added. Tried execute once but then i just get 1 tag created

Please share your workflow

    ]
  ]
},
"Create WP With All tags": {
  "main": [
    []
  ]
}

},
“pinData”: {}
}

  • n8n version: latest
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker self hosted
  • Operating system: ubuntu

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

Hi @aidiva

I think what is happening is your workflow is passing multiple items down the workflow and therefore will create one post for each item in the workflow.

You could try and add a code node after your set items node to bring all of the tag ID’s together and then use that as an expression in the post to WP node.

Here’s an example of the function to use in the code node:

let tagIds = [];
items.forEach(item => {
    if (item.json.body && item.json.body.length > 0 && item.json.body[0].id) {
        // Push the ID to the array
        tagIds.push(item.json.body[0].id);
    }
});
const tagIdsString = tagIds.join(',');
return [{
    json: {
        tagIds: tagIdsString
    }
}];

This should return:

[
{
"tagIds": 
"19,20,21"
}
]

and use the expression in the post to WP node.

You might need to play around with that a little more - for example, I think another issue you will have is where you have the Set Node. As you have an IF node and you need the input from both branches, you probably will need a Set Node at the end of both branches that is set up the same on both branches to output the same thing, then a merge node to pull them both together

Hey thanks for replying. I actually used an aggregate node after the Set after posting as realised the issue is this

Set TAGID = a list of tags and Wordpress wants and Array of TAGIDs

But still cant get the correct array output for the tagIDs grrr!

Tried your code but it doesnt output the tag ids as an array sadly -

See the set tag IDs - its correctly picking up ALL the tag IDs but i then need to convert this to an array and cant work out how to correctly do that

Thanks


hey finally have it working after WAY too long - thanks for pointing me in the right direction. I actually got it working with an Aggregate array in the end woo hoo!

Cool. Good to hear you got
It working.

1 Like

hey thanks - see my later post - ive got it working using the aggregate node - it seems i had not been setting this up to create an array correctly. Thanks for the input :grinning:

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