Code Uncategorized WordPress

Thoughts on Post Meta Boxes in WordPress

I’m generally of the opinion that the screen for adding content should be as simple as possible in a CMS.  It’s one of the reasons I really like the new Distraction Free Writing in WordPress 3.2 (sneak peek if case you haven’t seen it).  It’s why I was a huge fan of WordPress reducing the number of default metabox in 3.1.

This is why in the recently updated AddThis WordPress plugin, the meta box to disable AddThis on a post by post basis is disabled by default.  While it was a feature that users requested, it wasn’t something that people were beating down the door to enable.  I decided that thus for the majority of users, no reason to make the display show more than they need.

It was super simple code wise. All of this code sits inside of a class that controls all of the post meta box:

// These two lines are inside a function the hooks into init. $screen equals post and page
add_meta_box(‘addthis’, ‘AddThis’, array($this, ‘post_metabox’), $screen, ‘side’, ‘default’ );
add_filter(‘default_hidden_meta_boxes’, array($this, ‘default_hidden_meta_boxes’ ) );

function default_hidden_meta_boxes($hidden)
$hidden[] = ‘addthis’;
return $hidden;

Now the addthis metabox will be hidden by default. Next time you add a post meta box to WordPress inside a plugin, ask your self if it’s one that all of your plugin users will need.

Learn more about AddThis for WordPress 2.1

4 replies on “Thoughts on Post Meta Boxes in WordPress”

I’m impressed with your thoughts on this (though of course I’m not surprised). Some plugin authors won’t put the user’s experience ahead of the plugin’s branding and identified importance.

I think the reason more plugin dev’s don’t use this, is because they simply didn’t know how. I tried to find the code to do this (searched core), knowing it had to be simple, but couldn’t find it (at 3 a.m. might have had something to do with it). Thanks so much for the tip Aaron!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.