Skip to content

Instantly share code, notes, and snippets.

@kurudrive
Last active August 16, 2021 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurudrive/289dd8c9594216e10a1f94e14186c3eb to your computer and use it in GitHub Desktop.
Save kurudrive/289dd8c9594216e10a1f94e14186c3eb to your computer and use it in GitHub Desktop.
予約投稿の即時公開
/**
* 予約投稿機能を無効化
*/
function my_disable_future_publish( $id, $post ) {
global $wpdb;
// 即時公開対象の投稿タイプを指定
if ( 'post' === $post->post_type ) {
$sql = 'UPDATE `' . $wpdb->prefix . 'posts` ';
$sql .= 'SET post_status = "publish" ';
$sql .= 'WHERE post_status = "future"';
$wpdb->get_results( $sql );
}
}
add_action( 'save_post', 'my_disable_future_publish', 99, 2 );
add_action( 'edit_post', 'my_disable_future_publish', 99, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment