通过子主题自定义元框
Customize meta box through child theme
我正在使用便士拍卖 wordpress 主题,因为我是 wordpress 的新手。我的问题是通过使用子主题在侧面元框中添加更多字段,为此我已经成功创建并激活了子主题,但我被困在这里如何通过使用子主题功能在元框中添加更多文本字段文件?
最简单的方法是安装 Meta Box 插件 (https://wordpress.org/plugins/meta-box/),然后将其添加到您子主题的 functions.php 文件中:
function yourprefix_register_meta_boxes( $meta_boxes ) {
$prefix = 'metaboxprefix_';
$meta_boxes[] = array(
'id' => 'samplefield',
'title' => __( 'Your Meta Box Title', 'yourtextdomain' ),
'post_types' => 'post',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => __( 'Your Text Field', 'yourtextdomain' ),
'id' => $prefix . 'yourfieldid',
'type' => 'text',
),
)
);
return $meta_boxes;
}
add_filter( 'rwmb_meta_boxes', 'yourprefix_register_meta_boxes' );
供将来参考:http://metabox.io/
我正在使用便士拍卖 wordpress 主题,因为我是 wordpress 的新手。我的问题是通过使用子主题在侧面元框中添加更多字段,为此我已经成功创建并激活了子主题,但我被困在这里如何通过使用子主题功能在元框中添加更多文本字段文件?
最简单的方法是安装 Meta Box 插件 (https://wordpress.org/plugins/meta-box/),然后将其添加到您子主题的 functions.php 文件中:
function yourprefix_register_meta_boxes( $meta_boxes ) {
$prefix = 'metaboxprefix_';
$meta_boxes[] = array(
'id' => 'samplefield',
'title' => __( 'Your Meta Box Title', 'yourtextdomain' ),
'post_types' => 'post',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => __( 'Your Text Field', 'yourtextdomain' ),
'id' => $prefix . 'yourfieldid',
'type' => 'text',
),
)
);
return $meta_boxes;
}
add_filter( 'rwmb_meta_boxes', 'yourprefix_register_meta_boxes' );
供将来参考:http://metabox.io/