add_meta_box() is, and always has been, only defined in the admin area.
You can use add_meta_box() in your themes functions.php, you just need to only execute it on admin requests, for example:
add_action('admin_init', 'mytheme_admin_init');
function mytheme_admin_init() {
add_meta_box(....);
}
Aha, great, thanks! That definitely helps. I was confused because I could do things like have actions for custom post types and lots of other things to do with posts, but apparently not create a meta box for a post without it being in admin_init. Inconsistencies ftl.
When it comes to the themes functions.php, you shouldn’t really be running anything outside of actions. ie. All code should be wrapped in functions hooked to init or later usually (Aside from theme setup stuff, which can be hooked to ‘after_setup_theme’)
So the only functions you should call in functions.php are add_filter() and add_action()
Have a look at TwentyTen’s functions.php for an example of this: http://core.trac.ww.wp.xz.cn/browser/trunk/wp-content/themes/twentyten/functions.php#L50