thenameisnick
Member
Posted 2 months ago #
I have a series of functions that run when a post is published, but I don't want them to run on any updates to that post.
I tried testing the 'post_status' with:
if (!$_POST['post_status'] == 'publish') {
do stuff
}
but to no avail. Any ideas?
Thanks!
There's probably a cleaner way of doing this, but
if( ( $_POST['post_status'] == 'publish' ) && ( $_POST['original_post_status'] != 'publish' ) ) {
echo "New post!";
}
If you compare the original post status and the new one, that should show whether it's an update or not :)
thenameisnick
Member
Posted 2 months ago #
Kawauso, that seems to be working perfectly. Many thanks!