Custom Posts Working with Custom Write Panels?
-
This is basically ready for WP3 but i wondered if it can be done..
I have been using this custom write panel tut and want to combine it with the custom posts feature.
Here is my functions.php doing its job..
/* Custom Post Details */ register_post_type('post-test', array( 'label' => 'Post Test', 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array('slug' => ''), 'query_var' => true, 'supports' => array('title','editor','excerpt','thumbnail',)) ); /* Custom Write Panel Details */ $key = "key"; $meta_boxes = array( /*Test Box*/ "previous" => array( "name" => "test", "title" => "test link", "description" => "testing info"), /*Test Box*/ "next" => array( "name" => "testing", "title" => "testing link", "description" => "testing info"), ); function create_meta_box() { global $key; if( function_exists( 'add_meta_box' ) ) { add_meta_box( 'new-meta-boxes', ucfirst( $key ) . ' Site Detail Options', 'display_meta_box', 'post', 'normal', 'high' ); } } function display_meta_box() { global $post, $meta_boxes, $key; ?> <div class="form-wrap"> <?php wp_nonce_field( plugin_basename( __FILE__ ), $key . '_wpnonce', false, true ); foreach($meta_boxes as $meta_box) { $data = get_post_meta($post->ID, $key, true); ?> <div class="form-field form-required"> <label for="<?php echo $meta_box[ 'name' ]; ?>"><?php echo $meta_box[ 'title' ]; ?></label> <input type="text" name="<?php echo $meta_box[ 'name' ]; ?>" value="<?php echo $data[ $meta_box[ 'name' ] ]; ?>" /> <p><?php echo $meta_box[ 'description' ]; ?></p> </div> <?php } ?> </div> <?php } function save_meta_box( $post_id ) { global $post, $meta_boxes, $key; foreach( $meta_boxes as $meta_box ) { $data[ $meta_box[ 'name' ] ] = $_POST[ $meta_box[ 'name' ] ]; } if ( !wp_verify_nonce( $_POST[ $key . '_wpnonce' ], plugin_basename(__FILE__) ) ) return $post_id; if ( !current_user_can( 'edit_post', $post_id )) return $post_id; update_post_meta( $post_id, $key, $data ); } add_action( 'admin_menu', 'create_meta_box' ); add_action( 'save_post', 'save_meta_box' );
The problem is that the custom write panel only appears in the default posts, not my newly added custom post.
So is there anyway to tell the custom posts to include the custom write panel..?
Or no chance..
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Custom Posts Working with Custom Write Panels?’ is closed to new replies.