mysql - WordPress将帖子的最后修改日期更改为发布日期(预定的帖子)

标签 mysql wordpress plugins modified-date

我有一个想法来更改 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/

相关文章:

mysql - 为什么整数数据被插入到 'varchar' 列而不给出单引号?

php - Woocommerce 的 Flatsome : Annul file within INC folder

php - get_results ("select * from table_name where id IN($array)")但它假设 $array 为 "Array"

c# - 任务(或线程)需要 Wait 或 Join 才能工作

gradle - 控制台窗口中的 Intellij 插件开发打印

mysql - 如何提高 Django 管理搜索相关字段的查询性能 (MySQL)

MySQL:WHERE IN 列表的限制结果

php - mySQL blob 图像打印输出?

wordpress - 将产品属性添加到古腾堡 Woocommerce 的 block 中

java - 如何在项目资源管理器上下文菜单中添加弹出菜单,仅适用于项目中的 .java 文件