Home > Internet > Update massive data in WordPress

Update massive data in WordPress

There comes a time that must be upgraded large amounts of data in a repetitive way on WordPress.

A recent example is the case of hyperlinks paths with fixed permalinks. Migrating to Geofumadas.com and leave the subdomain requires adjustment in many of these fields, as shown in the following example:

The previous route was:

http://galvarezhn.cartesianos.com/curso-de-autocad-2011/

And the new is:

clip_image001http://geofumadas.com/curso-de-autocad-2011/

It is clear that what is needed is to change the term galvarezhn.cartesianos.com by geofumadas.com and do it for a large amount of data requires doing so from the database, if the site where blog is hosted allows this. Let’s see how to do it:

1.  The backup.

Before you do something crazy like this, it’s better to download a backup. This is done in Tools / Export.

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

clip_image002

3. Find tables that contain the word to change. Let us remember that this term may be in different tables, for example the wp_posts entries, the comments wp_comments, etc. So what we do first is determine where it is. To do this, we select the “search” tab, write the searched word and select all the tables.

clip_image003

And that should display us an output similar to the picture below.

clip_image004

4. Search columns where are placed words to be changed.

With the “Browse” button you can go to the detail of the column where is placed. This is done by simple inspection.

5. Execute the change

What’s next is to run changes with the following syntax:

update table set column = replace(column, ‘text to change‘, ‘ new text‘)

update wp_posts set post_content = replace(post_content, ‘http://galvarezhn.cartesianos.com/‘, ‘http://geofumadas.com/‘)

In this case, the table is wp_post and post_content column. When you run, it should appear a message of how many records were affected. Be careful on using the symbol (‘ ) because is not the same as that used for accent (´). If we don’t, it will return an error message in the syntax.

It’s ideal then to rerun the query from step 3, for seeing if the result has changed. It also should be suitable go step by step, verifying the change, lest a finger error leads us to place vertical bar spare or something of that sort.

Nor is it advisable to make this process if first actions such as import images that could be stored in the previous blog have not previously been executed. If we don’t do this, we will be breaking the correct path and causing irreversible damage. For that task, there are plugins such as LinkedImages and also WordPress recent versions; so when importing, gives us the option of bringing images to the new hosting (although they are not all).

Leave a Reply

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