Last active
August 16, 2021 09:01
-
-
Save kurudrive/289dd8c9594216e10a1f94e14186c3eb to your computer and use it in GitHub Desktop.
予約投稿の即時公開
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 予約投稿機能を無効化 | |
*/ | |
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