WordPress.org

Ready to get started?Download WordPress

Forums

OptionTree
Checkbox - how to default to checked? (4 posts)

  1. ronronmx
    Member
    Posted 1 year ago #

    How can I force a checkbox to be checked by default in a metabox? Here's my code below:

    array(
     'id'      => 'platform_link_target',
     'label'   => 'Link Target',
     'desc'    => 'Do you want the link to open in a new window?',
     'std'     => '',
     'type'    => 'checkbox',
     'class'   => '',
     'choices' => array(
    
        array(
         'label'	=> 'Yes',
         'value'	=> '_blank'
        )
      )
    )

    Thanks in advance!
    Stephane

    http://wordpress.org/extend/plugins/option-tree/

  2. mattmatt88
    Member
    Posted 1 year ago #

    I have the same question.
    Please help!

  3. Yojance
    Member
    Posted 1 year ago #

    I think you may have to use some jQuery for this. Add a CSS class when you create the option and then register a script to run in the admin section which takes care of checking the checkbox.

  4. ronronmx
    Member
    Posted 1 year ago #

    Well I don't want to put that much work into it, I thought there might have been a default option I missed like 'default' => 'true' for example.

    Thanks for the answer anyways Yojance!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic