【问题标题】:Customize meta box through child theme通过子主题自定义元框
【发布时间】:2016-07-25 13:56:53
【问题描述】:

我正在使用一分钱拍卖 wordpress 主题,因为我是 wordpress 新手。我的问题是通过使用子主题在侧面元框中添加更多字段,因此我已经成功创建并激活了子主题,但我被困在这里如何使用子主题功能在元框中添加更多文本字段文件?

【问题讨论】:

    标签: php wordpress plugins customization meta-boxes


    【解决方案1】:

    最简单的方法是安装 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/

    【讨论】:

      猜你喜欢
      • 2023-04-11
      • 2015-01-21
      • 2013-04-12
      • 1970-01-01
      • 2023-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-03
      相关资源
      最近更新 更多