0

I'm using CPT library and I don't understand how can I add the class attribute on a single input field, I create all the post input as array item:

array( 
    'label' => esc_html__( 'Property Structure Type', 'zoacres' ),
    'desc'  => esc_html__( 'Choose related structure type of this property. You can manage property structure type settings at Theme Options -> Property Settings -> Property General -> Property Structure Types', 'zoacres' ), 
    'id'    => $prefix.'structures',
    'tab'   => esc_html__( 'Property Details', 'zoacres' ),
    'type'  => 'text',
    'options'   => $property_structures_arr,
    'attributes' => array(
         'class' => 'main-container'
     )
),

essentially the code above create a text field, but I want add the class main-container to that input, seems that attributes is not the way to achieve this.

What I did wrong?

official documentation: http://codex.pluginize.com/cptui/v1.5.0/package-CPTUI.Taxonomies.html

7
  • $attributes is part of the labels array and, AFAIK, doesn't have anything to do with the classes associated with input elements (BTW, are you talking about the front end or the back end?). Perhaps you can try using a generator to create the CPT? Sep 25, 2019 at 14:19
  • WordPress does not have an API that accepts those arguments for a custom post type field. Are you using a framework or plugin for fields? Sep 25, 2019 at 14:20
  • FWIW “Property Structure Types” really sounds like it should be a taxonomy. Sep 25, 2019 at 14:21
  • @JacobPeattie I'm trying to customize the theme zoacres, and apparently this theme is based on CPT, I didn't found nothing in the documentation which explain how to add a custom class on the generated input. The author of the theme has added the array above using this function: $property_box = new Custom_Add_Meta_Box
    – sfarzoso
    Sep 25, 2019 at 14:24
  • Are you trying to add a class to the field on the edit screen, or the front end? Sep 25, 2019 at 14:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.