3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

《WordPress》特定の投稿タイプの予約投稿を無効にする。(未来の日付でも即時投稿できるようにする)

Posted at

したいこと

記事を未来の日付で投稿すると通常なら予約投稿になりますが、未来の日付の投稿でも即時に記事が表示されるようにしてみます。

function.phpに記述します。

コード


function disable_scheduled_posting_func( $data, $postArray ) {
  if ( ( $data['post_type'] == 'my_post_type' && $data['post_status'] == 'future') && $postArray['post_status'] == 'publish' ) {
    $data['post_status'] = 'publish';
  }
  return $data;
};
add_filter( 'wp_insert_post_data', 'disable_scheduled_posting_func', 10, 2 );

if文のmy_post_typeの部分に任意の投稿タイプを記述します。


$data['post_type'] == 'your_post_type'

おわります。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?