Update bulk data in WordPress

The time comes for WordPress to update large amounts of data, in a repetitive way.

A recent example is the case of hyperlink routes were with fixed permalinks, move to Geofumadas.com and exit the subdomain requires adjustment in many of these fields, as I show in the following example:

The previous route was:

http://geofumadas.cartesianos.com/ course-of-autocad-2011 /

and the new one is:

http://Geofumadas.com/ course-of-autocad-2011 /

It is clear that what is required is to change the term geofumadas.cartesianos.com by Geofumadas.com and doing it for a large amount of data is necessary from the database, if the place where the blog is hosted allows us to do so. Let's see how to do it:

 at export 1 The backup.

Before doing something crazy like this, you have to download a backup. This is done in Tools / Export.

2 Access phpMyAdmin. In this case, I'm doing it from Cpanel, which is the platform where Geofumadas.com is hosted. Once inside we choose the database, there should usually be only one.

 at export

3 Find which tables contain the word to change. Recall that this term can be in different tables, for example the entries wp_posts, comments wp_comments, etc. So what we do first is to determine where it is. To do this, select the "search" tab, write down the searched word and select all the tables.

 at export

And that should show us a similar result to the bottom image.

 at export

4 Find the columns where the words to change are.

With the "Browse" button you can go to the detail of the column where you are. This is done by simple inspection.

5 Execute the change

What comes next is to execute the change with the following syntax:

Update table set columna = replace (columna, 'text to change','new text‘)

Update wp_posts set post_content = replace (post_content, 'geofumadas.cartesianos.com','Geofumadas.com‘)

In this case, the table is wp_post, and the post_content column. When executing it, the message of how many records were affected must appear. You have to be careful with using the symbol (') because it is not the same as the one used for accent ('). If not, an error message will return in the syntax.

It is then ideal to rerun the query, from step 3, to see if the result changed. It is also convenient to go step by step, verifying the change, lest a finger error lead us to place a leftover or something like that.

It is also not advisable to do this process if you have not previously performed actions such as importing images that could have been stored in the previous blog. If we do not, we will be breaking the correct path and causing irreversible damage. For that there are plugins like LinkedImages and also the recent versions of WordPress when importing gives us the option to bring the images to the new hosting (although not all of them come).

Leave an answer

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.