I'm creating a WordPress plugin where it is required to show the meta box only when a post is being published for the first time.

The only way I can think of is to show the metabox iff there is no $_GET['post'] parameter set(it represents the post ID), but then meta box will not be visible for the posts which are in draft.

Is there any way to determine if the post has been published before?

1 Answer 1


I haven't tested this but the idea is to check the post status, if the post is not published, show the metabox otherwise don't.

function non_publish_metaboxes() {
    global $post;


    if($post->post_status !== 'publish'){
        // ... Show Metabox
add_action( 'add_meta_boxes', 'non_publish_metaboxes' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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