Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

marked as duplicate by toscho Jul 9 '12 at 18:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

<?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.

share|improve this answer
add comment

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