# Radio

The Radio field is an excellent way to present a set of choices for users to select from.

# Arguments

Name
Type
Default Description
type string radio Value identifying the field type.
options array Deprecated in Redux 4.0.3, though still fully functional. Accepts an array of key pair values representing the radio buttons. The key value should be numbers in sequential order, beginning with 1.  The value parameter accepts the text to display beside the radio button.
data string | array Pass in a string to auto-fetch WordPress Data as expected from the data argument. Will also accept an array of key pair values representing the radio buttons. The key value should be numbers in sequential order, beginning with 1.  The value parameter accepts the text to display beside the radio button.

# Build Config

Build a Custom Configuration →
Changes you make to this form will be reflected in the generated code.
Field visibility requirements.

Redux::set_field( 'OPT_NAME', 'SECTION_ID', array(
    'type' => 'radio'
) );

# Example Config using Array

Redux::addField( 'OPT_NAME', 'SECTION_ID', array(
    'id'       => 'opt-radio',
    'type'     => 'radio',
    'title'    => __('Radio Option', 'redux-framework-demo'), 
    //Must provide key => value pairs for radio options
    'data'  => array(
        '1' => 'Opt 1', 
        '2' => 'Opt 2', 
        '3' => 'Opt 3'
    ),
    'default' => '2'
) );

# Example Config using WordPress Data

Redux::addField( 'OPT_NAME', 'SECTION_ID', array(
    'id'      => 'opt-radio',
    'type'    => 'radio',
    'title'   => __('Radio Option', 'redux-framework-demo'), 
    'data'    => 'pages',
    'default' => '2'
) );

# Example Usage

This example in based on the example usage provided above. Be sure to change $redux_demo to the value you specified in your opt_name argument. Only the key of the select options or data array item will be returned.

global $redux_demo;

echo 'Selected Radio value: ' . $redux_demo['opt-radio'];