comparision of old and new post

source : wp-hackers digest # 67,15,7.

add_action( 'transition_post_status', 'whatever', 10, 3 );
function whatever( $new, $old, $post ) {
// compare $new and $old and act accordingly
}

Basically, when $new is publish and $old is anything else, then you know a post is getting published for the first time. Or whatever your own criteria are. You can also examine $post to check for other things, like post_type or something. If it doesn't fit your criteria, just return without doing anything.
 
 
Creative Commons License
This work by maniac.vardhan is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
 
 

0 comments :: comparision of old and new post

Post a Comment