Whenever in doubt about the functioning of WordPress functions, consult the Codex:
http://codex.wordpress.org/Function_Reference/register_post_type
There, we can see that when registering a post type the supports
argument has many options, one of them custom-fields
.
So, this would enable the CF box for the CPT:
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'custom-fields' )
);
Also, there’s a missing closing </div>
in the function member_manager_meta_options
.
[UPDATE]
I’ll mark this Q&A for closure as too localized. The problems with it are errors in the post meta key names and wrong reading of a variable values.
If the following debug info is dumped inside the function member_manager_meta_options
, you’ll see why no values are being read (because they are being saved).
$values =get_post_custom($post->ID);
echo '<pre>' . print_r( $values,true ) . '</pre>';
So, a working function would be:
function member_manager_meta_options(){
global $post;
$values =get_post_custom($post->ID);
//echo '<pre>' . print_r( $values,true ) . '</pre>';
$id = isset( $values["isprp_id" ]) ? esc_attr($values["isprp_id" ][0]) : ' ';
$member_life = ( 'Life Member' == $values["isprp_member" ][0] ) ? 'checked' : '';
$member_assoc = ( 'Associate Member' == $values["isprp_member" ][0] ) ? 'checked' : '';
wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );
?>
<div class="member_manager_extras">
<style type="text/css">
<?php include('member_manager.css'); ?>
</style>
<div>
<label for="isprp_id">ISPRP ID</label>
<input type="text" name="isprp_id" id="isprp_id" value ="<?php echo $id; ?>" />
</div>
<div>
<label for="isprp_member">Membership Category</label>
<input type="radio" name="isprp_member" value="Life Member" <?php echo $member_life; ?> />Life Member
<input type="radio" name="isprp_member" value="Associate Member" <?php echo $member_assoc; ?> />Associate Member
</div>
<?php
}
And the problem of the post_meta
key names is that isprp_member
and isprpmember
(and ispr_id
as well) are not consolidated through the code. They are being used as Columns IDs and as Post Meta Keys.