Using WordPress ‘post_submit_meta_box()’ PHP function

The post_submit_meta_box WordPress PHP function displays post submit form fields in a meta box.

Usage

post_submit_meta_box($post, $args);

Input:

$post = WP_Post object;
$args = array(
    'id' => 'submitdiv',
    'title' => 'Publish',
    'callback' => 'post_submit_meta_box',
    'args' => array()
);

Parameters

  • $post (WP_Post) – Required. The current post object.
  • $args (array) – Optional. An array of arguments for building the post submit meta box:
    • id (string) – Meta box ‘id’ attribute.
    • title (string) – Meta box title.
    • callback (callable) – Meta box display callback.
    • args (array) – Extra meta box arguments. Default: array().

More information

See WordPress Developer Resources: post_submit_meta_box

Examples

Displaying the default post submit meta box

This example will display the default post submit meta box for the current post.

$post = get_post();
post_submit_meta_box($post, array());

Customizing the title of the post submit meta box

This example changes the title of the post submit meta box to ‘Save’.

$post = get_post();
$args = array(
    'title' => 'Save'
);
post_submit_meta_box($post, $args);

Adding an extra CSS class to the post submit meta box

This example adds a custom CSS class to the post submit meta box.

$post = get_post();
$args = array(
    'args' => array(
        'class' => 'custom-class'
    )
);
post_submit_meta_box($post, $args);

Adding a custom attribute to the post submit meta box

This example adds a custom data attribute to the post submit meta box.

$post = get_post();
$args = array(
    'args' => array(
        'attributes' => array(
            'data-custom' => 'custom-value'
        )
    )
);
post_submit_meta_box($post, $args);

Customizing the ID of the post submit meta box

This example changes the ID of the post submit meta box to ‘custom-submitdiv’.

$post = get_post();
$args = array(
    'id' => 'custom-submitdiv'
);
post_submit_meta_box($post, $args);