こんな感じのスクリプトをサーバの cron で毎分実行すれば、きっと大丈夫
post_status
が future
で、投稿日時が1時間前〜現在までの投稿があったら、wp_publish_post()
を実行して投稿処理を実施します。
#!/bin/bash
WP_ROOT=${1:-/var/www/html}
WPCLI="wp --path=${WP_ROOT}"
table_prefix=$(${WPCLI} eval 'global $table_prefix; echo $table_prefix;')
post_ids=$(${WPCLI} db query "select ID from ${table_prefix}posts where post_status = 'future' and post_date BETWEEN (NOW() - INTERVAL - 1 hour) AND NOW() order by post_date_gmt;" | awk '{print $1}' | grep -v 'ID')
for post_id in ${post_ids}; do
echo ${post_id}
${WPCLI} eval "wp_publish_post(${post_id});"
done