Skip to main content
Best answer

Adding links to WordPress content sourced from YouTube description


janosch.hrm
Forum|alt.badge.img

Hey there,

 

I’ve set up an automation with Zapier that runs whenever I publish a new YouTube video on my channel. The automation creates a post in WordPress by uploading the YT thumbnail as a featured image, title as a title and the link to the video as well as the YT video description as the post content. 

 

The problem I’m facing is that the links from my YT caption aren’t showing up as clickable links in the WordPress post. I’d love for this to be fixed, so that users on my website could read through the description and instantly click on the links. 

 

Is there a way to achieve this? I basically just need the URLs that are in the video description to be clickable...

Best answer by GetUWired

var result = inputData.description.replace(/(\b(https?|ftp|file):\/\/[\-A-Z0-9+&@#\/%?=~_|!:,.;]*[\-A-Z09+&@#\/%=~_|])/img, '<a href="$1">$1</a>');

return {'formattedOutput': result};


Here’s the javascript that I used in that code action, which includes the regex expression.

View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

8 replies

GetUWired
Forum|alt.badge.img+12
  • Zapier Expert
  • 1030 replies
  • March 2, 2021

The easiest way to do this would be with a code action that uses a regex expression to replace your URLs with anchor tags before adding it to the Wordpress post.

 


janosch.hrm
Forum|alt.badge.img
  • Author
  • Beginner
  • 10 replies
  • March 2, 2021

@GetUWired  thank you for your answer!

 

Do you have a RegEx that would do this? That would be great!


GetUWired
Forum|alt.badge.img+12
  • Zapier Expert
  • 1030 replies
  • Answer
  • March 2, 2021

var result = inputData.description.replace(/(\b(https?|ftp|file):\/\/[\-A-Z0-9+&@#\/%?=~_|!:,.;]*[\-A-Z09+&@#\/%=~_|])/img, '<a href="$1">$1</a>');

return {'formattedOutput': result};


Here’s the javascript that I used in that code action, which includes the regex expression.


janosch.hrm
Forum|alt.badge.img
  • Author
  • Beginner
  • 10 replies
  • March 2, 2021

@GetUWired  Unfortunately I can’t seem to make it work. I get the following error back from Zapier when testing the zap:

 


janosch.hrm
Forum|alt.badge.img
  • Author
  • Beginner
  • 10 replies
  • March 3, 2021

@GetUWired any update on this? I’m probably doing something wrong, but I can’t seem to figure it out :sweat_smile:


GetUWired
Forum|alt.badge.img+12
  • Zapier Expert
  • 1030 replies
  • March 3, 2021

@janosch.hrm 
Would you mind sharing a screenshot of how you have your code set up? 


janosch.hrm
Forum|alt.badge.img
  • Author
  • Beginner
  • 10 replies
  • March 4, 2021

@GetUWired Never mind, I actually got it to work now. I think I had a type in the name of the input field. Thank you so much for your help!


GetUWired
Forum|alt.badge.img+12
  • Zapier Expert
  • 1030 replies
  • March 4, 2021

@janosch.hrm 

That’s great to hear! Glad we could help out!