Skip to content
Advertisement

Redux Framework switch type

how to use redux framework switch type in wordpress themes?

if ( $my_opt_name ) { do something }

or

if ( $my_opt_name === '1' ) { do something }

or

if ( $my_opt_name == '1' ) { do something }

or

if ( $my_opt_name == 1 ) { do something }

or

if ( $my_opt_name === 1 ) { do something }

or

if ( $my_opt_name == true ) { do something }

I worked with all of this and that works Properly but sometimes does not work.

Advertisement

Answer

You can follow this steps.

Step-1: use this type of code to add switch, and focus on id value.

$fields = array(
    'id'       => 'opt-switch',
    'type'     => 'switch', 
    'title'    => __('Switch On', 'redux-framework-demo'),
    'subtitle' => __('Look, it's on!', 'redux-framework-demo'),
    'default'  => true,
);

Step-2: Use this code to use switch

global $redux_demo;
if( $redux_demo['opt-switch']){
 //Do Something if switch is on(i.e - true)
}

Try that , then let me know the result. Thanks

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement