我使用的终极版框架主题发展,但我还是坚持上Metabox。我想这个文档https://docs.reduxframework.com/extensions/metaboxes/但我没有得到任何结果。
我无法得到选择自定义后类型的自定义字段。
在一些推广-的init.php,我发现:
//放在扩展目录内的所有扩展将被自动加载你的终极版实例。终极版:: setExtensions($ opt_name,目录名(文件) '/扩展/');
// Any custom extension configs should be placed within the configs folder.
if ( file_exists( dirname( __FILE__ ) . '/configs/' ) ) {
$files = glob( dirname( __FILE__ ) . '/configs/*.php' );
if ( ! empty( $files ) ) {
foreach ( $files as $file ) {
include $file;
}
}
}
它清楚地表明了定制metabox将从CONFIGS文件夹负载,但其不加载。
尝试更多的东西像这样的......注意,你需要ADD_ACTION(
if ( !function_exists( "master_metaboxes_function" ) ){
function master_metaboxes_function($master_metaboxes) {
if ( file_exists( dirname( __FILE__ ) . '/configs/' ) ) {
$files = glob( dirname( __FILE__ ) . '/configs/*.php' );
if ( ! empty( $files ) ) {foreach ( $files as $file ) {include $file;} }
}
return $master_metaboxes;
}
// note this has to load AFTER the action loads...
add_action('redux/metaboxes/'.$YOUR_OPTION_ID.'/boxes', 'master_metaboxes_function');
}
阅读:https://github.com/reduxframework/redux-framework/issues/2605
正如你可以在文档中看到,你需要挂接到一个过滤器来设置你的metaboxes,所以在你的插件或主题,添加以下代码:
(别忘了更换{$ redux_opt_name}你唯一的供应商前缀/ opt_name,以防止与其他插件colissions)
if ( !function_exists( "{%redux_opt_name%}_redux_add_metaboxes" ) ):
function {%redux_opt_name%}_redux_add_metaboxes($metaboxes) {
// Declare your sections
$boxSections = array();
$boxSections[] = array(
//'title' => __('General Settings', 'redux-framework-demo'),
//'icon' => 'el-icon-home', // Only used with metabox position normal or advanced
'fields' => array(
array(
'id' => 'sidebar',
//'title' => __( 'Sidebar', 'redux-framework-demo' ),
'desc' => 'Please select the sidebar you would like to display on this page. Note: You must first create the sidebar under Appearance > Widgets.',
'type' => 'select',
'data' => 'sidebars',
),
),
);
// Declare your metaboxes
$metaboxes = array();
$metaboxes[] = array(
'id' => 'sidebar',
'title' => __( 'Sidebar', 'fusion-framework' ),
'post_types' => array( 'page', 'post', 'acme_product' ),
//'page_template' => array('page-test.php'), // Visibility of box based on page template selector
//'post_format' => array('image'), // Visibility of box based on post format
'position' => 'side', // normal, advanced, side
'priority' => 'high', // high, core, default, low - Priorities of placement
'sections' => $boxSections,
);
return $metaboxes;
}
// Change {%redux_opt_name%} to your opt_name
add_filter("redux/metaboxes/{%redux_opt_name%}/boxes", "redux_add_metaboxes");
endif;