WordPress Redx Framework — создать поле повторителя и показать значения позже

Я пытаюсь использовать Redux внутри темы WordPress, а не в качестве плагина. В functions.php Я включил оба redux-framework.php а также sample-config.php ,

Теперь мне нужно создать поле повторителя.

От Redux Doc, Я получил следующий код, чтобы использовать для создания поля повторителя:

$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' ),
),
)
)
)
);

но если я помещу код внутри functions.phpчто будет $this переменная относится к? Это приведет к ошибкам. Итак, как использовать фрагмент, чтобы я также мог получать значения из файлов шаблонов?

0

Решение

Вы должны попробовать старую версию системы, чтобы создать раздел. Вы можете попробовать новую версию системы, я не уверен, работает ли она или нет, но вы можете попробовать так:

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' ),
),
)
)
)
));
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru