PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 18, 2022

[FIXED] Bulk change Year only in worpdress posts

 February 18, 2022     mysql, phpmyadmin, wordpress     No comments   

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
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing