scheduled event not getting executed

You can’t add an action to wp_head inside a wp-cron job. The wp-cron tasks run outside of the normal flow, so while you can add your action, it won’t actually do anything to anybody viewing the page. Cron jobs are called via separate http requests, no user normally will see their results.

In other words, your code works fine, it just doesn’t do what you’re expecting it to do. Although to be honest, I’m not entirely sure what you were expecting it to do. You certainly won’t see any change to the content of the page header, if that’s what you were thinking.

Leave a Comment