With WP CLI I was able to avoid other plugins potentially interfering with publish_future
post.
Below is a perl fragment. On my host webdir is $HOME/public_html
and bindir is /usr/bin
. Note the use of --due-now
. Only those hooks currently waiting to be fired will run. Also note you either need to cd
into webdir or add --path=path
, where path is the path to the wordpress files (usually webdir).
# Post any scheduled posts ready to publish
my $cmd = "cd <webdir>; <bindir>/wp cron event run publish_future_post --due-now;
system($cmd);
# Run other cron events normally
$cmd = "cd <webdir>; <bindir>/php wp-cron.php";
system($cmd);
Then I set the script to run at 1,31 in my system cron as all posts either are scheduled for the top of the hour or the bottom of the hour.