0
0

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.

ある階層の固定ページのステータスを保存時に"予約投稿"から"公開済み"にする

Last updated at Posted at 2018-05-30

以下のコードは、id=xxxxの固定ページの子要素で"予約投稿"を無効化して、強制的に"公開済み"にする。

function.php
// 予約投稿を公開済みに変更する

function force_publish_page( $data, $postarr ) {
  if (
    $data['post_type'] == 'page' && 
    $data['post_parent'] == xxxx && 
    $data['post_status'] == 'future'
   ) {
    $data['post_status'] = 'publish';
  }
  return $data;
};
add_filter( 'wp_insert_post_data', 'force_publish_page', 10, 2 );
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?