1

の値を変更する考えがあるpost_modifiedので、値は と同じ値になりpost_dateます。

post_modifiedしかし、Wordpress にはリビジョン システムがあるので、リビジョン上の を と同じ値に変更したいと考えています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->IDposts テーブルのリビジョン ID です。

しかし、クエリを実行すると、値が変更されず、プラグインが停止します。

私が逃したものはありますか?それとも、Wordpress 自体が変更を許可していないのpost_modifiedでしょうか?

4

2 に答える 2

2

通常の wp_update_post 関数を使用できます

    $args = new stdClass;
    $args->ID = $yourPostIdVal;
    $args->post_modified = $yourDateString;
    $args->post_modified_gmt = $yourGmDateString;
    wp_update_post($args);
于 2017-01-12T16:00:00.137 に答える
0

post_date を更新しようとしたときに、この問題と同じように直面しました。最後に、「`」マークを使用して列名をラップしました。次のように正確に実行します。

$postID = $update->ID;
$datetime = date("Y-m-d H:i:s");   



$wpdb->query( "UPDATE `$wpdb->posts` SET 
                                    `post_date` = '".$datetime."'
                                    WHERE `ID` = '".$postID."'" );

$datetime は、2015-01-04 または 2015-01-04 23:59:59 のような有効な日付です。

これが助けになることを願っています。ありがとう

于 2015-01-04T07:51:20.723 に答える