How to Remove HubSpot CTA Button Strings in HubSpot to WordPress Migration


How to Remove HubSpot CTA Button Strings in HubSpot to WordPress Migration

When migrating a HubSpot blog to WordPress or another CMS you will often find text strings in your articles that look like this {{cta('4cdfhg-a57e-dfh-dfh-5c6dfhgdfhdfgc','justifycenter')}}

Most likely you are going to replace those with a new button pointing to a landing page but that takes time to update. Also doing a database find and replace would work but that can also be risky because you are not 100% sure what and where things are being changed.

A safer option would be to use javascript to hide the text string on the frontend. This will also help later on when the site is indexed in Google because you can search your site for that string and manually update the posts when you have the time.

Below is some code to help you find all HubSpot CTA strings in your blog posts. Add this to a javascript file loaded in your site.

// Hide HubSpot CTA text strings
var str = jQuery("article").html();
var regex = /\{{cta(.*?)\}}/g;
// if you want to completely remove it
//jQuery("article").html(str.replace(regex, ' '));
jQuery("article").html(str.replace(regex, '<span class="hs-cta">$&</span>'));  

View codepen demo


Written by: Jake Lett
Jake Lett is a B2B marketing consultant with over 15 years of experience in the digital marketing industry. He specializes in SEO, HubSpot, and PPC campaign management. Jake has a proven track record of helping businesses increase their online visibility and drive more traffic, leads and sales. He is a Certified Google Ads Specialist and a Certified HubSpot Developer.

Related posts

Tags: , , ,

Want to Get Email Updates of New Articles?

Join My Email Newsletter