Skip to content

Instantly share code, notes, and snippets.

@gatespace
Last active April 6, 2018 11:11
Show Gist options
  • Save gatespace/223be667a863029d1608c19af5f3f4aa to your computer and use it in GitHub Desktop.
Save gatespace/223be667a863029d1608c19af5f3f4aa to your computer and use it in GitHub Desktop.
[WordPress] WP Post Branches で更新された元記事の公開日時を変更しない ref: https://qiita.com/gatespace/items/19232316662afdd04e35
add_filter( 'wpbs_draft_to_publish_update_post', 'my_wpbs_draft_to_publish_update_post', 10, 1 );
function my_wpbs_draft_to_publish_update_post( $new ) {
// 元記事の更新日時をブランチ記事の公開日時にする
$new['post_modified'] = $new['post_date'];
$new['post_modified_gmt'] = $new['post_date_gmt'];
// 元記事の公開日時は変更しない
$old_id = $new['ID'];
$old_post = get_post( $old_id );
$new['post_date'] = $old_post->post_date;
$new['post_date_gmt'] = $old_post->post_date_gmt;
return $new;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment