最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

css - Cannot add a class to metabox

programmeradmin1浏览0评论

I'm trying to add a class to the metabox, for doing so I have created the metabox element in this way:

array( 
    'label' => esc_html__( 'Property Lot Size', 'zoacres' ),
    'desc'  => esc_html__( 'Enter lot size of property by number. Do not use any special characters like comma, dot etc... Example 10000', 'zoacres' ), 
    'id'    => $prefix.'lot_size',
    'tab'   => esc_html__( 'Property Details', 'zoacres' ),
    'type'  => 'text',
    'default'   => ''
    'class' => 'zoacres-main'
),

the code above generate the metabox but I doesn't have the class zoacres-main why?

I'm trying to add a class to the metabox, for doing so I have created the metabox element in this way:

array( 
    'label' => esc_html__( 'Property Lot Size', 'zoacres' ),
    'desc'  => esc_html__( 'Enter lot size of property by number. Do not use any special characters like comma, dot etc... Example 10000', 'zoacres' ), 
    'id'    => $prefix.'lot_size',
    'tab'   => esc_html__( 'Property Details', 'zoacres' ),
    'type'  => 'text',
    'default'   => ''
    'class' => 'zoacres-main'
),

the code above generate the metabox but I doesn't have the class zoacres-main why?

Share Improve this question edited Sep 25, 2019 at 11:51 Johansson 15.4k11 gold badges43 silver badges79 bronze badges asked Sep 25, 2019 at 11:01 faccendafaccenda 212 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You didn't mention the library you're using to generate this meta, but i guess it's the cmb2 library, if it's so then you should change your array params as follow :

array( 
    'label' => esc_html__( 'Property Lot Size', 'zoacres' ),
    'desc'  => esc_html__( 'Enter lot size of property by number. Do not use any special characters like comma, dot etc... Example 10000', 'zoacres' ), 
    'id'    => $prefix.'lot_size',
    'tab'   => esc_html__( 'Property Details', 'zoacres' ),
    'type'  => 'text',
    'default'   => '',
    'attributes' => array(
       'class' => 'zoacres-main'
     )
),

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论