1

I've used the Settings API in the past to output text inputs and checkboxes but am unsure if I can use file inputs.

My add_settings_field() is:

add_settings_field( '1', 'File 1', array( $this, 'my_callback' ), 'files', 'files' );

My callback function:

public function my_callback() {     
    echo '<input type="file" name="file" />';
}

I assume the next step is to handle the image upload. My problem is how do I do this using the Settings API? I am aware I can set a callback function as the 3rd parameter in register_setting() so my guess is I can use wp_handle_upload() in that callback. I'm looking for some guidance or confirmation that this is the approach I should take. Thanks in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.