Using WordPress ‘page_attributes_misc_attributes’ PHP action

The page_attributes_misc_attributes WordPress action fires before the help hint text in the ‘Page Attributes’ meta box.

Usage

add_action('page_attributes_misc_attributes', 'your_custom_function', 10, 1);

function your_custom_function($post) {
    // Your custom code here

    return $post;
}

Parameters

  • $post (WP_Post) – The current post.

More information

See WordPress Developer Resources: page_attributes_misc_attributes

Examples

Add custom text to ‘Page Attributes’ meta box

Add a custom text message to the ‘Page Attributes’ meta box.

add_action('page_attributes_misc_attributes', 'add_custom_text', 10, 1);

function add_custom_text($post) {
    echo '<p><strong>Note:</strong> This is a custom text message.</p>';
}

Display the post status

Display the current post status in the ‘Page Attributes’ meta box.

add_action('page_attributes_misc_attributes', 'display_post_status', 10, 1);

function display_post_status($post) {
    echo '<p><strong>Post Status:</strong> ' . $post->post_status . '</p>';
}

Show the current post type

Display the current post type in the ‘Page Attributes’ meta box.

add_action('page_attributes_misc_attributes', 'display_post_type', 10, 1);

function display_post_type($post) {
    echo '<p><strong>Post Type:</strong> ' . $post->post_type . '</p>';
}

Display the author of the post

Show the author of the current post in the ‘Page Attributes’ meta box.

add_action('page_attributes_misc_attributes', 'display_post_author', 10, 1);

function display_post_author($post) {
    $author = get_userdata($post->post_author);
    echo '<p><strong>Post Author:</strong> ' . $author->display_name . '</p>';
}

Show the post creation date

Display the post creation date in the ‘Page Attributes’ meta box.

add_action('page_attributes_misc_attributes', 'display_post_date', 10, 1);

function display_post_date($post) {
    echo '<p><strong>Post Creation Date:</strong> ' . date('F j, Y', strtotime($post->post_date)) . '</p>';
}