Search code examples
phpwordpressredux-framework

redux framework opt_text not display the value


i tired to fix this i have problem with redux framework options options-init.php

    Redux::setSection( $opt_name, array(
    'title'  => __( 'Basic Field', 'redux-framework-demo' ),
    'id'     => 'basic',
    'desc'   => __( 'Basic field with no subsections.', 'redux-framework-demo' ),
    'icon'   => 'el el-home',
    'fields' => array(
        array(
            'id'       => 'opt-text',
            'type'     => 'text',
            'title'    => __('Text Option - Email Validated', 'redux-framework-demo'),
            'subtitle' => __('This is a little space under the Field Title in the Options table, additional info is good in here.', 'redux-framework-demo'),
            'desc'     => __('This is the description field, again good for additional info.', 'redux-framework-demo'),
            'validate' => 'email',
            'msg'      => 'custom error message',
            'default'  => '[email protected]'
        )
    )
) );

this is my index.php

<h1><?php global $opt_name; echo 'Text value: ' . $opt_name['opt-text']; ?></h1>

i get this error Warning: Illegal string offset 'opt-text' in C:\xampp\htdocs\wordpress\wp-content\themes\ZoXX\index.php on line 2


Solution

  • Redux hasn't loaded yet. Delay your use of the variable, or run:

    Redux::init('OPT_NAME')
    

    Good luck!