Using WordPress ‘dbx_post_sidebar’ PHP action

The dbx_post_sidebar WordPress PHP action fires after all meta box sections have been output, before the closing #post-body div. It works with the post object.

Usage

add_action('dbx_post_sidebar', 'your_custom_function');
function your_custom_function($post) {
  // your custom code here

  return $post;
}

Parameters

  • $post (WP_Post) – The post object.

More information

See WordPress Developer Resources: dbx_post_sidebar

Examples

Add a custom message after meta boxes

Add a custom message after all meta boxes have been displayed.

add_action('dbx_post_sidebar', 'add_custom_message');
function add_custom_message($post) {
  echo '<div class="custom-message">**Remember to add tags and categories!**</div>';
  return $post;
}

Display post ID

Display the current post ID after the meta boxes.

add_action('dbx_post_sidebar', 'display_post_id');
function display_post_id($post) {
  echo 'Current Post ID: **' . $post->ID . '**';
  return $post;
}

Show post type

Show the current post type after the meta boxes.

add_action('dbx_post_sidebar', 'show_post_type');
function show_post_type($post) {
  echo 'Post Type: **' . $post->post_type . '**';
  return $post;
}

Display post status

Display the current post status after the meta boxes.

add_action('dbx_post_sidebar', 'display_post_status');
function display_post_status($post) {
  echo 'Post Status: **' . $post->post_status . '**';
  return $post;
}

Display post author

Display the current post author after the meta boxes.

add_action('dbx_post_sidebar', 'display_post_author');
function display_post_author($post) {
  $author_id = $post->post_author;
  $author = get_userdata($author_id);
  echo 'Post Author: **' . $author->display_name . '**';
  return $post;
}