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

Get a Free HubSpot CMS Guide
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


Related posts

Tags: , , ,

Want to Get Email Updates of New Posts? Join My Email Newsletter