Update bulk data in Wordpress
The time has come when large amounts of data must be updated repeatedly in Wordpress.
A recent example is the case where the hyperlink paths were with fixed permalinks, going to Geofumadas.com and leaving the subdomain requires adjusting 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 it is necessary to do it from the database, if the place where the blog is hosted allows it. Let's see how to do it:
1. The backrest.
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 am doing it from Cpanel, which is the platform where Geofumadas.com is hosted. Once inside we choose the database, generally there should only be one.
3. Find which tables contain the word to change. Remember that this term can be in different tables, for example the one with the wp_posts entries, the one with the comments wp_comments, etc. So what we do first is determine where it is. To do this, we select the "search" tab, write down the search word and select all the tables.
And that should show us a similar result to the bottom image.
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 column is post_content. When executing it, the message of how many records were affected should appear. You have to be careful with using the symbol (') as it is not the same as the one used for accent (´). If not, it will return an error message in the syntax.
It is ideal then to run the query again, from step 3, to see if the result has changed. It is also convenient to go step by step, verifying the change, lest a finger mistake lead us to place a spare plate or something like that.
It is also not recommended to carry out this process if actions such as importing images that could have been stored in the previous blog have not been carried out before. If we don't, we will be breaking the correct route 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).