Possible Duplicate:
Check if post is being published for the first time, or is an already published post being updated

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.


1 Answer 1

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.