# WordPressで「予約投稿の失敗」となってしまう場合の対処方法 URL: https://webrandum.net/wordpress-reservation-posting-failure/ 公開日: 2022-04-09 更新日: 2022-04-09 カテゴリー: コーディング タグ: WordPress 出典: Webrandum(著者: サイトウ マサカズ) WordPressの予約投稿機能を使えば、指定した日時になると自動的に公開されて便利です。 しかし最近WordPressで「予約投稿の失敗」と表示されて投稿がうまくできない事象が発生しました。 ## 発生した事象 WordPressの管理画面で「予約投稿の失敗」と表示されて、記事は投稿されずに残っている状態です。 ![予約投稿の失敗](https://webrandum.net/mskz/wp-content/uploads/2022/04/image_1-3.png) ## 対処方法 とりあえず再度予約投稿を設定しなおしたら正常に動作しましたが、今後発生しないためにいくつか対策を調べました。 ### 代替Cronを使用する WordPressの予約投稿機能は「疑似Cron」と呼ばれる仕組みで動いていて、時間がきたら実行するのではなく時間がきたタイミングでファイルにアクセスがあると実行します。 そのため、アクセスが全くなかったり、キャッシュプラグインを使用していてファイルへアクセスされないと失敗することがあるようです。 ただ、疑似Cronが失敗したときに代わりに動作する「代替Cron」という仕組みが用意されています。 設定はWordPressのインストールディレクトリ直下にある`wp-config.php`に、下記の一文を追加するだけで対応できます。 ``` define('ALTERNATE_WP_CRON', true); ``` これだけで設定できるので、この方法が一番簡単そうです。 ### 予約投稿プラグインを使用する 予約投稿プラグインを使用しても解決できます。 有名なのは「[Scheduled Post Trigger](https://ja.wordpress.org/plugins/scheduled-post-trigger/)」や「[SchedulePress](https://ja.wordpress.org/plugins/wp-scheduled-posts/)」が有名です。 [![](https://www.google.com/s2/favicons?domain=ja.wordpress.org)WordPress.org 日本語![](//webrandum.net/mskz/wp-content/uploads/pz-linkcard/cache/b2cf573e3893e638cfabf1052183b79c569618b137098d853ab13fdd204c27a1.webp)Scheduled Post Triggerhttps://ja.wordpress.org/plugins/scheduled-post-trigger/Checks to see if any scheduled posts have been missed. If so, it publishes them. NOTE: This plugin is meant as a stop-gap until you and your web host …](https://ja.wordpress.org/plugins/scheduled-post-trigger/) [![](https://www.google.com/s2/favicons?domain=ja.wordpress.org)WordPress.org 日本語![](https://s.wordpress.com/mshots/v1/https%3A%2F%2Fja.wordpress.org%2Fplugins%2Fwp-scheduled-posts%2F?w=160)SchedulePress – Best Editorial Calendar, Missed Schedule & Auto Social Share ...https://ja.wordpress.org/plugins/wp-scheduled-posts/A complete solution for WordPress Post Schedule. Manage schedule through editorial calendar and enable auto scheduler. Also handles auto social share …](https://ja.wordpress.org/plugins/wp-scheduled-posts/) 他にもいくつかありますが、プラグインの更新日がかなり古かったりするので、インストール時は「最終更新日」と「検証済み最新バージョン」を確認して使うようにしましょう。 ただ、予約投稿のためだけにプラグインをインストールするのは手間ですし、メンテナンスを考えると代替Cronを使用した方がよさそうです。