WordPress の wp_cron についてのメモ書です。 WordPress では wp_cron と呼ばれる擬似 cron 機能がついていて、任意の処理を定期実行する仕組みがあります。 今回は、これを使って任意の処理を定期実行する方法をメモしておこうと思います。 スポンサーリンク wp_cron に処理を追加するフック テストとしてメールを送信する処理を wp_cron に登録してみます。 コードはこんな感じ。 if ( ! wp_next_scheduled( 'my_cron_event' ) ) { wp_schedule_event( time(), 'hourly', 'my_cron_event' ); } function my_cron_mail() { wp_mail( 'hoge@example.jp', 'テストメール', 'WordPress wp_cron