I’m trying to create an “admin only” meta box using WPAlchemy. The box for example may contain a “feature post” check box and other functionality.
How can I show this meta box for only the admin, yet have it work properly? I’m currently using the following code below, but I receive a “Fatal error: Call to a member function the_meta() on a non-object” when trying to echo the value of whatever is inside on the front-end. Everything works as intended if I don’t use current_user_can and works also if I’m logged in as admin and viewing the front-end.
if (current_user_can('administrator')) {
$custom_admin_mb = new WPAlchemy_MetaBox(array(
'id' => '_custom_admin_meta',
'title' => 'Admin only',
'template' => TEMPLATEPATH . '/custom/admin_meta.php',
));
}
try the following: