Custom meta box not showing up
-
I’ve created a custom post type and now need to attach a custom meta box to the edit context. The code I’ve cobbled together is not doing anything that I can see.
Here’s some of the relevant bits:
class Fixtures { public function __construct() { add_action( 'init', array(&$this,'create_post_type')); add_action( 'add_meta_box', array(&$this,'fixtures_add_custom_meta_box')); } function create_post_type() { /* code works - omitted */ } public function fixtures_add_custom_meta_box() { error_log( __FUNCTION__ ); // never shows up in debug.log add_meta_box( 'fixtures-metabox' ,'Fixture Attributes' ,array(&$this, 'render_custom_meta_box') ,'post' ,'normal' ,'high' ); } public function render_custom_meta_box() { error_log( __FUNCTION__ ); // never shows up in debug.log wp_nonce_field( plugin_basename( __FILE__ ), 'fixtures_noncename' ); // the actual fields presented by the meta_box // - potential parents - only none, other fixtures // - ordering number // we omit the template option for now to simplify the plugin $value = get_post_meta( $post->ID, '_fixtures_parent_id', true ); echo '<label for="fixtures_parent_id">'; echo 'Parent Fixture'; echo '</label> '; echo '<input type="text" id="fixtures_parent_id" name="fixtures_parent_id" value="'.esc_attr($value).'" />'; $value = get_post_meta( $post->ID, '_fixtures_order', true ); echo '<label for="fixtures_order">'; echo'Order'; echo '</label> '; echo '<input type="text" id="fixtures_order" name="fixtures_order" value="'.esc_attr($value).'" size="4" />'; } } $fixtures = new Fixtures();
Any insights greatly appreciated.
~ Erik
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Custom meta box not showing up’ is closed to new replies.