1
問題:當WP領域POST_DATE更新時,場post_date_gmt也應該被更新,但事實並非如此。我發現,在做更新的插件之一的功能:更新與在WordPress wp_update_post
function KBM_Reposter_move_oldest_post($kbm_Reposter_Catagory_ID) {
global $logrr;
$logrr -> logDebug("Start: " . __FUNCTION__);
$kbm_Reposter_Get_Post_Arguments = array('post_type' => 'post', 'numberposts' => 1, 'category' => $kbm_Reposter_Catagory_ID, 'post_status' => 'publish', 'orderby' => 'post_date', 'order' => 'ASC');
$kbm_Reposter_Old_Posts = get_posts($kbm_Reposter_Get_Post_Arguments);
if ($kbm_Reposter_Old_Posts) {
foreach($kbm_Reposter_Old_Posts as $kbm_Reposter_Oldest_Post) {
$kbm_Reposter_Oldest_Post->post_date = date_i18n('Y-m-d H:i:s');
$result = wp_update_post($kbm_Reposter_Oldest_Post);
if (!is_wp_error($result) AND $result > 0) {
$logrr -> logNotice("Post updated, id=$result");
}
}
} else {
$logrr -> logNotice("No post found for repost!");
}
$logrr -> logDebug("End: " . __FUNCTION__);
}
的wp_update_post更新的字段。我認爲需要改變線路是這樣的:
$kbm_Reposter_Oldest_Post->post_date = date_i18n('Y-m-d H:i:s');
如何用相同的日期作爲wp_update_post的部分更新post_date_gmt場?在此先感謝
那麼post_date_gmt包含post_date的gmt等價物嗎? – Jack
是的,確切地說。如果您不希望gmt等價,但只需要與post_date中的日期相同,請使用$ kbm_Reposter_Oldest_Post-> post_date_gmt = date_i18n('Y-m-d H:i:s'); –