How to update short...
Clear all

How to update shortcodes (or other elements) sitewide using MySQL queries

380433b0c0305034cd333db1e6823e78?s=110&d=identicon&r=x - Forum
Member Admin

I recently did some work for a client who had dozens of MemberMouse purchase shortcodes on his site.

We created a new product to replace the old product and needed to update ALL of the shortcodes to reflect this.

Doing this manually would've taken forever.

So my client, who has some sweet programming chops, emailed me the next day to tell me he had simply run a MySQL query to replace all of the shortcodes.

It looks like this:

UPDATE wp_posts SET post_content = REPLACE (
'MM_Member_Decision membershipId='9'',
'MM_Member_Decision hasBundle='1'');

UPDATE wp_posts SET post_content = REPLACE (
'MM_Member_Decision membershipId="!9"',
'MM_Member_Decision hasBundle='!1'');

UPDATE wp_posts SET post_content = REPLACE (
'MM_Purchase_Link productId='8'',
'MM_Purchase_Link productId='9'');

In this case we're replacing all instances of the shortcodes in red text with the shortcodes in green text, site wide.

To learn how to run MySQL queries visit this great post


*Please note that there is a WordPress plugin called WordPress SQL Executioner that will allow you to run MySQL queries without going into your PHPMyAdmin panel inside your hosting account.

Topic starter Posted : 27/03/2015 9:36 pm