Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    If you create a new tab, and want to use multiple fields in that tab, then it should use this structure.

    add_filter( 'wpsl_meta_box_fields', 'custom_meta_box_fields' );
    
    function custom_meta_box_fields( $meta_fields ) {
        
        $meta_fields[__( 'Custom tab', 'wpsl' )] = array(
            'custom-1' => array(
                'label' => __( 'Custom 1', 'wpsl' )
            ),
            'custom-2' => array(
                'label' => __( 'Custom 2', 'wpsl' )
            ),
        );
    
        return $meta_fields;
    }
    • This reply was modified 5 years, 5 months ago by Tijmen Smit.
    Thread Starter sergejos

    (@sergejos)

    Yes, I used this.

    But I have to specify the type of the field or not? And I don’t know, how to specify both fields within the custom_frontend_meta_fields function as a text field.

    add_filter( 'wpsl_frontend_meta_fields', 'custom_frontend_meta_fields' );
    
    function custom_frontend_meta_fields( $store_fields ) {
    
        $store_fields['wpsl_my_textinput'] = array( 
            'name' => 'my_textinput',
            'type' => 'text'
        );
        
        return $store_fields;
    }
    

    Here I can only specify one field and I don’t know, how to edit the array $store_fields so that both fields (Custom 1 and Custom 2) are text fields.

    Plugin Author Tijmen Smit

    (@tijmensmit)

    If no type is provided, then it will default to text.

    You can simply repeat it like this.

      $store_fields['wpsl_my_textinput'] = array( 
            'name' => 'my_textinput'
        );
    
      $store_fields['wpsl_other_textinput'] = array( 
            'name' => 'other_textinput'
        );
    Thread Starter sergejos

    (@sergejos)

    Thank you, it worked!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Create two additional fields’ is closed to new replies.