When attaching a function in functions.php to save_post I found out it runs my code twice.
Finally found a solution using:
1 2 3 4 5 6 7 8 9 |
$post_type = get_post_type( $post_id ); if ($post_type=='revision') { return; } if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )||$_POST['post_type']=='revision') { return; } |