wordpress redux框架 - 创建一个转发器字段并稍后显示值

I am trying to use Redux inside the wordpress theme and not as a plugin. In functions.php I included both redux-framework.php and sample-config.php .

Now I need to create a repeater field.

From Redux doc, I got the following code to use in order to create a repeater field:

$this->sections[] = array(
    'title' => __('Repeater Field', 'redux-framework-demo' ),
    'icon' => 'el-icon-thumbs-up',
    'fields' => array(
        array(
            'id'         => 'repeater-field-id',
            'type'       => 'repeater',
            'title'      => __( 'Title', 'redux-framework-demo' ),
            'subtitle'   => __( '', 'redux-framework-demo' ),
            'desc'       => __( '', 'redux-framework-demo' ),
            //'group_values' => true, // Group all fields below within the repeater ID
            //'item_name' => '', // Add a repeater block name to the Add and Delete buttons
            //'bind_title' => '', // Bind the repeater block title to this field ID
            //'static'     => 2, // Set the number of repeater blocks to be output
            //'limit' => 2, // Limit the number of repeater blocks a user can create
            //'sortable' => false, // Allow the users to sort the repeater blocks or not
            'fields'     => array(
                array(
                    'id'          => 'title_field',
                    'type'        => 'text',
                    'placeholder' => __( 'Title', 'redux-framework-demo' ),
                ),
                array(
                    'id'          => 'text_field',
                    'type'        => 'text',
                    'placeholder' => __( 'Text Field', 'redux-framework-demo' ),
                ),
                array(
                    'id'          => 'select_field',
                    'type'        => 'select',
                    'title' => __( 'Select Field', 'redux-framework-demo' ),
                    'options'     => array(
                        '1'             => __( 'Option 1', 'redux-framework-demo' ),
                        '2'             => __( 'Option 2', 'redux-framework-demo' ),
                        '3'             => __( 'Option 3', 'redux-framework-demo' ),
                    ),
                    'placeholder' => __( 'Listing Field', 'redux-framework-demo' ),
                ),
            )
        )
    )
);

but if I place the code inside functions.php, what will the $this variable refer to? It'll produce errors. So how to use the snippet so that I can retrieve the values from template files as well?

You have to tried an old version system to create a section. You can try the new version system, I'm not sure if this works or not, but you can try this way:

Redux::setSection($opt_name, array(
    'title'             => __('Ads Sections', 'cbnews'),
    'id'                => 'ads-sections',
    'desc'              => __('You can manage your ads', 'cbnews'),
    'icon'              => 'dashicons dashicons-dashboard',
    'fields'            => array(
        array(
            'id'         => 'repeater-field-id',
            'type'       => 'repeater',
            'title'      => __( 'Title', 'redux-framework-demo' ),
            'subtitle'   => __( '', 'redux-framework-demo' ),
            'desc'       => __( '', 'redux-framework-demo' ),
            //'group_values' => true, // Group all fields below within the repeater ID
            //'item_name' => '', // Add a repeater block name to the Add and Delete buttons
            //'bind_title' => '', // Bind the repeater block title to this field ID
            //'static'     => 2, // Set the number of repeater blocks to be output
            //'limit' => 2, // Limit the number of repeater blocks a user can create
            //'sortable' => false, // Allow the users to sort the repeater blocks or not
            'fields'     => array(
                array(
                    'id'          => 'title_field',
                    'type'        => 'text',
                    'placeholder' => __( 'Title', 'redux-framework-demo' ),
                ),
                array(
                    'id'          => 'text_field',
                    'type'        => 'text',
                    'placeholder' => __( 'Text Field', 'redux-framework-demo' ),
                ),
                array(
                    'id'          => 'select_field',
                    'type'        => 'select',
                    'title' => __( 'Select Field', 'redux-framework-demo' ),
                    'options'     => array(
                        '1'             => __( 'Option 1', 'redux-framework-demo' ),
                        '2'             => __( 'Option 2', 'redux-framework-demo' ),
                        '3'             => __( 'Option 3', 'redux-framework-demo' ),
                    ),
                    'placeholder' => __( 'Listing Field', 'redux-framework-demo' ),
                ),
            )
        )
    )
));