settings api – How I can Make two input field at add_settings_section

Question

How I can make two input fields in the add_settings_section?
I want the First Input type to be text
The second Input type is the Select option
and Inside Foreach
and here is an exmple:

function myplugin_function($args){
  global $plugin_get_opts;
    

    $cars = array(
        '0' => 'Marcedes',
        '1' => 'BMW',
        '2' => 'Borj'
    );
?>
                
                foreach($cars as $obj){
                        
                ?>

                                    
  <input type="text" name="plugin_opts[<?php echo esc_attr($args['name']); ?>][]"
   value="<?php echo esc_attr($obj);?>">

<select name="plugin_opts[<?php echo esc_attr($args['unit']); ?>][]" id="<?php echo esc_attr($args['id']); ?>"">
    <option value="blue" <?php selected(@$plugin_get_opts[$args['unit']],'blue'); ?>>Blue</option>
    <option value="red" <?php selected(@$plugin_get_opts[$args['unit']],'red'); ?>>red</option>
    <option value="white" <?php selected(@$plugin_get_opts[$args['unit']],'white'); ?>>white</option>
</select>
        

0
Ahmed java 1 year 2021-12-23T07:20:42-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse