Once a year I have an issue I run into that needs an elegant solution. I need to take every instance of the keyword 2014 (or whatever the current year is) in my page content, SEO meta tag titles and descriptions and switch it over to the new year.
The first year I did this I manually went through each page and title and painstakingly changed them. Since then I’ve obtained quite a few more pages to manage and my yearly routine is much faster.
For those of you brave enough to wander into your mySQL database and make some permanent changes this solution will find and replace anything you want really quickly.
*Be aware that any changes you make in this way could break your site if you’re not careful so be sure to back up your database first.
What to do
Navigate to your mySQL database. For me this is a PHP myAdmin control panel that I find through my Plesk control panel in my MediaTemple hosting account.
Once you’re in click on wp_posts under your database tables on the left. After that click the SQL tab that runs along the top. Then delete the pre-written query that’s in there and replace it with this.
UPDATE wp_posts SET post_content = REPLACE (
Essentially you’re telling the database to look in the table wp_posts for the column post_content and replace anything in that column that matches space 2014 with space 2015. The space is important because if you don’t include that it will break all of your images that are stored in that column that were uploaded in that year (ie http://www.getnichequick.com/wp-content/uploads/2014/10/theseidlers.jpg). The space essentially make it look for natural content.
I’ll run this query twice. Once with the space in front and once with it in the back in case there was a period or other character butted up against either end.
To do the same for All-In-One SEO meta title and meta description tags I’ll query a different table.
This time I go to wp_postmeta where AIOSEO stores its data and run run the query in the meta_value column.
UPDATE wp_postmeta SET meta_value = REPLACE (
What you get in the end is every page on your site containing the keyword 2014 being instantly converted and relevant to the new year of 2015. I’ve messed with plugins that supposedly run database queries like this before, but have never had luck. This is the only way I’ve been able to accomplish mass find and replaces like this.
Hope it helps someone else out there. Let me know if it works for you in the comments below.