Trying to Get Text Field to Save

I am creating my own options page for a plugin and I am having trouble getting my text field to save. My code looks like this:

function setup_fields() {
add_settings_field(‘my_first_field’, ‘Field name’, ‘field_callback’, ‘myplugin’, ‘my_first_section’);
add_action(‘admin_init’, ‘setup_fields’);

function field_callback($arguments) {
echo ‘<input name=”my_first_field” id=”my_first_field” type=”text” value=”‘ . get_option(‘my_first_field’, ‘default’) . ‘” />’;
register_setting(‘myplugin’, ‘my_first_field’);

When I write into the text field on my page and click “Save Changes” it always switches back to my “default.” i’m a beginner so I apologize if this is a vague or basic question. Thank you!

Read more here:: Trying to Get Text Field to Save

Leave a Reply

Your email address will not be published. Required fields are marked *