我有一个想法来更改 post_modified
的值,因此该值将与 post_date
具有相同的值。
但是 WordPress 有一个修订系统,因此我想将修订版上的 post_modified
更改为与 post_date
具有相同的值。
这是我更改它的查询:
$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
是 posts 表中的修订 ID。
但是当我运行查询时,它不会更改值并停止我的插件。
是不是我漏掉了什么?还是Wordpress本身不允许我们更改post_modified
?
最佳答案
您可以使用普通的wp_update_post函数
$args = new stdClass;
$args->ID = $yourPostIdVal;
$args->post_modified = $yourDateString;
$args->post_modified_gmt = $yourGmDateString;
wp_update_post($args);
关于mysql - WordPress将帖子的最后修改日期更改为发布日期(预定的帖子),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27308459/