Best answer

Get WordPress Tags From Post

  • 28 April 2020
  • 1 reply
  • 159 views

When a new post is added to my WordPress blog, I want to get it and put it into a Google Sheet I have.

While I have been able to set this up for the most part through Zapier, one issue I'm having is that I can't seem to get the tags for the post.

From googling this, I did see that you could do this by adding this code to a code app

var termsNameArray = input.termsName.split(",");
var termsTaxonomyArray = input.termsTaxonomy.split(",");

for (var i = 0; i < termsNameArray.length; i++) {
if(termsTaxonomyArray[i] !== 'post_tag'){
termsNameArray.splice(i, 1);
}
}

var output = {};

for (var i = 0; i < termsNameArray.length; i++) {
var outputKey = 'tag_' + (i + 1).toString();
output[outputKey] = termsNameArray[i];
}

However, this is from 4 years ago and so when I tried it, it didn't seem to work anymore. Is there another way to do this perhaps potentially using this as a starting point?

icon

Best answer by nicksimard 29 April 2020, 00:39

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 7
Badge +11

Hi @Growler,

I think you could use a Formatter step before tackling something like that code you mentioned. Under the Utilities section of the Formatter you can find some functions that let you work with line items. And it appears that WordPress tags are coming through as line items.

Can you check that out to see if you can get it doing what you need?