Distinguish between publish and update?

I’m writing a plugin which needs to grab posts as their published from one blog – but I’m finding that despite using the requirement that they be published and not revisions, when the post is updated, it’s sending across a duplicate.

Is there any way to determine whether a post has been published and is being updated? My alternative is to add a custom post meta field which says its already been grabbed by the plugin – but this isn’t ideal in comparison to a solution that requires no additional fields.

Related posts

Leave a Reply

1 comment

  1. <?php
    add_action( 'save_post', 'your_action' );
    
    function your_action( $post_id ) {
    
        if ( !wp_is_post_revision( $post_id ) ) {
            // Do this only if not a revision
        }
    }
    ?>
    

    Use the if condition to check if post is not revision.