• Resolved boutwell

    (@boutwell)


    I have multiple authors that I run a “mass approval” query to posts all of their entries once a week:

    UPDATE wp_posts SET post_status = ‘publish’ WHERE post_status = ‘draft’;

    This has a very strange side effect though. The posts dates all become “0000-00-00 00:00:00” only on the entries effected by the querey. Running a second querey:

    UPDATE wp_posts SET post_date = ‘2006-10-22 19:00:00’ WHERE post_date = ‘0000-00-00 00:00:00’;

    …does correct the problem, but why is this happening in the first place? I would aprove the posts manually if I could, but there are typically over 100 of them so its pretty tiresome.

    Any ideas?

    Thanks!

    Boutwell

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    The timestamp of a post is not generally set until the post is actually published. Drafts get a zero timestamp, as you may have noticed. The reasoning here is that somebody may work on a draft for a long time, and would probably not want to have it backdated to the time they started working on it when they actually decide to publish it.

    I would change your update query to set the post_date and post_date_gmt to the current time (and current GMT time) at the time you publish the post. Yes, it makes your query a bit more complex…

    Thread Starter boutwell

    (@boutwell)

    Ahhh..I was not aware of that. In that case, I will just continue with the two queries. Its only a few extra seconds and when I experiment with sql, I tend to break things ??

    Thanks very much for the resonse, Otto.

    Boutwell

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘zero dates after running UPDATE funtion’ is closed to new replies.