How to add a meta-box to an admin page in WordPress

I’ve been developing a plug-in for Powet.TV to automate some background stuff that we do regularly.
One of the things I need to do is add a meta-box to the ‘edit post’ administration page. The below image is an example of a very simple meta-box. Its just a standard container for content in the administration panel.

This wasn’t as straight-forward as I expected it to be, or I should say, there weren’t any examples that were as straight-forward as I was hoping there would be. The best tutorial I found was located here. The problem with this tutorial was that it didn’t spell it out clearly enough for me. It was doing a few different things in the example and I just wanted a very simple meta-box without any functionality to start. My functionality was guaranteed to not match the functionality of the one in the example.

I really find it helpful when developers write up challenges they have faced and how they resolved them on their blogs. I wanted to give back by writing this up in a similar fashion for others to benefit.

In its most basic form, here is the code for the meta-box from the plug-in.

Plugin Name: Test Meta-Box
Plugin URI: ??
Description: Show a new meta-box in the edit post admin page
Author: Bradley Jacobs
Version: 0.1

// Hooks
// ==========

/* Add a new meta box to the admin menu. */
add_action('admin_menu','fm_create_meta_box' );

// Code
// ==========
* Function for adding meta boxes to the admin.
function fm_create_meta_box() {
add_meta_box( 'post-meta-boxes', __('Box Heading'), 'post_meta_boxes', 'post', 'side', 'high' );

function post_meta_boxes() {
echo("TEXT IN BOX");

Once you’ve gotten that box to appear, you can start adding functionality to it.
Perhaps more on that another time.

Leave a Reply

Your email address will not be published. Required fields are marked *