WordPress 3 botches my Custom Meta Box values on Save

First of all, this isn’t using custom post meta … you’re trying to retrieve categories and use the presence of those categories to check the boxes. I also don’t see any script to save the values once you’ve clicked them … When this did work, I assume it was a very hackish solution, so I’m not surprised that it’s unstable and has broken.

However, you can actually use custom post meta to do what it is you want to do. Use the following script instead:

// ===================
// = POST OPTION BOX =
// ===================

add_action('admin_menu', 'my_post_options_box');

function my_post_options_box() {
    if ( function_exists('add_meta_box') ) { 
        add_meta_box('categorydiv', __('Page Index Options'), 'post_categories_meta_box_modified', 'page', 'side', 'high');
    }
}

//adds the custom categories box
function post_categories_meta_box_modified() {
    global $post;
    if( get_post_meta($post->ID, '_noIndex', true) ) $noindexChecked = " checked='checked'";
    if( get_post_meta($post->ID, '_noFollow', true) ) $nofollowChecked = " checked='checked'";
?>
<div id="categories-all" class="ui-tabs-panel">
    <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
        <li id='noIndex' class="popular-category"><label class="selectit"><input value="noIndex" type="checkbox" name="chk_noIndex" id="chk_noIndex"<?php echo $noindexChecked ?> /> noindex</label></li> 
        <li id='noFollow' class="popular-category"><label class="selectit"><input value="noFollow" type="checkbox" name="chk_noFollow" id="chk_noFollow"<?php echo $nofollowChecked ?> /> nofollow</label></li>  
    </ul>
</div>
<?php
}

function save_post_categories_meta($post_id) {
    if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;

    $noIndex = $_POST['chk_noIndex'];
    $noFollow = $_POST['chk_noFollow'];

    update_post_meta( $post_id, '_noIndex', $noIndex );
    update_post_meta( $post_id, '_noFollow', $noFollow );

    return $post_id;
}

add_action('save_post', 'save_post_categories_meta');

This will store Boolean flags in the custom post meta fields “noIndex” and “noFollow”, retrieve the values of those fields to use in your custom meta box, and allow you to easily access them elsewhere in your site. Just use get_post_meta( $post->ID, 'meta-name', true ) to retrieve them.