WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Based on solved question from: How to add a checkbox element to attachments editor with example

Theres an example of multiple Checkboxes, for example: Colors, patterns, etc... A grouped list but using checkboxes?

Tips to save and remember checked options on edit?

Thanks in advance.

share|improve this question
It's the same thing , just add as many checkboxes as you'd like. – Bainternet Apr 2 '11 at 0:23
up vote 1 down vote accepted

Like @Bainternet said, it is the same thing. Taking the code from the question you linked to, you can do it like this:

function filter_attachment_fields_to_edit( $form_fields, $post ) {
    $foo = (bool)get_post_meta( $post->ID, 'foo', true );
    $bar = (bool)get_post_meta( $post->ID, 'bar', true );

    $form_fields['foo'] = array(
    'label' => 'Is Foo',
    'input' => 'html',
    'html' => '<label for="attachments-' . $post->ID . '-foo"> '.
        '<input type="checkbox" id="attachments-' . $post->ID . '-foo" name="attachments[' . $post->ID . '][foo]" value="1"' . ( $foo ? ' checked="checked"' : '' ) . ' /> Yes</label>  ',
    'value' => $foo,
    'helps' => 'Check for yes'

    $form_fields['bar'] = array(
    'label' => 'Is Bar',
    'input' => 'html',
    'html' => '<label for="attachments-' . $post->ID . '-bar"> '.
        '<input type="checkbox" id="attachments-'.$post->ID . '-bar" name="attachments[' . $post->ID . '][bar]" value="1"'.( $bar ? ' checked="checked"' : '' ).' /> Yes</label>  ',
    'value' => $bar,
    'helps' => 'Check for yes'

    return $form_fields;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.