I have created a custom field "headline" in posts that is handled by a checkbox. Now I want that when the post is saved and the checkbox is checked, all "headline" checkboxes are emptied in the other posts. If this works correctly there should only be one other post with that checkbox checked.

```
function createHeadlineField()
{
$post_id = get_the_ID();

if (get_post_type($post_id) != 'post') {
    return;
}

$value = get_post_meta($post_id, '_headline_field', true);
wp_nonce_field('headline_nonce_'.$post_id, 'headline_nonce');
?>
<div class="misc-pub-section misc-pub-section-last">
    <label><input type="checkbox" value="1" <?php checked($value, true, true); ?> name="_headline_field" /><?php _e('This post is the top Story', 'pmg'); ?></label>
</div>
<?php
}

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

if (
    !isset($_POST['headline_nonce']) ||
    !wp_verify_nonce($_POST['headline_nonce'], 'headline_nonce_'.$post_id)
) {
    return;
}

if (!current_user_can('edit_post', $post_id)) {
    return;
}
if (isset($_POST['_headline_field'])) {
    update_post_meta($post_id, '_headline_field', $_POST['_headline_field']);
} else {
    delete_post_meta($post_id, '_headline_field');
}

```

}

Has anybody a clue how to do that? I guess I have to query the posts for posts with \_headline\_field values and delete these before updating the actual post.

thx