• Resolved thenameisnick

    (@thenameisnick)


    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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 ??

    Thread Starter thenameisnick

    (@thenameisnick)

    Kawauso, that seems to be working perfectly. Many thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘publish_post action ONLY on publish, not update’ is closed to new replies.