I have an idea to change the value of post_modified
, so the value will have the same value with the post_date
.
But WordPress has a revision system, so I want to change the post_modified
on the revision to have a same value with post_date
.
Here is my query to change it:
$query = "UPDATE $wpdb->posts
SET
post_modified = '$recent->post_date',
post_modified_gmt = '$recent->post_date_gmt'
WHERE
ID = '$update->ID'";
$wpdb->query($query);
$recent->post_date is the post_date (scheduled time / time where our post will appear in the website)
$recent->post_date_gmt is post_date_gmt
$update->ID
is the revision ID in posts table.
But when I run the query, it doesn’t change the value and stops my plugin.
Is there something I missed? Or is it that WordPress itself doesn’t allow us to change the post_modified
?
You can use the normal wp_update_post function
I have faced same like this problem when I tried to update post_date.Finally I used “`” mark to wrap column names.Do that exactly as follows.
Remember, $datetime is a valid date, like 2015-01-04 or 2015-01-04 23:59:59
Hope this would be help.
Thanks