0
我想在WordPress主題內使用Redux,而不是作爲插件。在functions.php
我包括redux-framework.php
和sample-config.php
。WordPress的REDX框架 - 創建一箇中繼器字段,並稍後顯示值
現在我需要創建一箇中繼器字段。
從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
變量是指什麼?它會產生錯誤。那麼如何使用代碼片段,以便我可以從模板文件中檢索值?