Issue
I am trying to update ONLY the year for the publish date for all the posts AND pages on a wordpress sites.
By mistake i did a find and replace with a plugin and replaced 2018 with 2019. As a result of that, lots of posts are showing up as "Scheduled" as their publish date was changed to 2019. I actually only wanted to change the 2018 year in the posts/pages titles, not the publish dates.
I am wondering if this will work but I am concern it might damage the whole website. This is some code I found online:
UPDATE wp_posts
SET post_date = REPLACE(post_date, '2019-‘, '2018-')
WHERE post_date LIKE '%2018-%'
I am not sure if this is the correct code to run in phpmyadmin. I have backed up the website before doing any changes.
Solution
Use date specific function rather than string based.
UPDATE wp_posts
SET post_date = post_date + INTERVAL 1 YEAR
WHERE YEAR(post_date) = 2018;
Answered By - Dark Knight
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.