One simple solution is to check with the query string from the request:
if ( !empty( $_REQUEST['action'] ) && "edit" == $_REQUEST['action'] ) {
/* proceed */
}
But it is also a good practice to use @mmm’s suggestion since you are working with meta boxes where you have the $post
object in use. When composing a new post, there’s an automatically created post with a status of auto-draft
, so let’s proceed the meta box coding when the status is something other than auto-draft
, say publish
for instance:
if ( !empty( ( $status = get_post_status( $post->ID ) ) ) && "auto-draft" !== $status ) {
/* proceed */
}
Glad that helped.