• Skip to primary navigation
  • Skip to main content
  • Skip to footer
  • Books
    • Content Strategy for WordPress (2015)
    • WordPress for Web Developers (2013)
    • Beginning WordPress 3 (2010)
  • Blog
    • Content Modeling for WordPress
    • WordPress Hidden Gems
    • Web Design
  • Work
    • MLIS Class Projects (2019-2022)
    • Portfolio (2002-2019)
    • Services
    • WordPress Plugins
    • WordPress Themes
    • Presentations and Interviews
    • on GitHub →

Stephanie Leary

Writer, WordPress consultant, recent MLIS grad

  • About
    • Press Kit
    • Presentations and Interviews
  • Contact Me

Adding fields to existing options pages

June 17, 2010 Stephanie Leary 1 Comment

There are lots of tutorials on adding a whole new options page for your plugin, but adding just a field or two to one of the standard options pages is a little different.

<br />
function add_extra_privacy_options() {<br />
     add_settings_field('extra_privacy', 'Extra Privacy Option', 'extra_privacy_options', 'privacy', $section = 'default', $args = array());<br />
     register_setting('privacy', 'extra_privacy');<br />
}</p>
<p>add_action('admin_init', 'add_extra_privacy_options');<br />
     // displays the options page content<br />
     function extra_privacy_options() { ?></p>
<input name='extra_privacy' value='<?php echo get_option('extra_privacy'); ?>' /><br />
<?php<br />
}<br />

The first argument in the register_setting() function is the one that identifies which existing page you want to use.

The new field on the Privacy settings page

That’s all you have to do! Just replace the form fields with your own. You’re using the Settings API, so your option will be saved and updated for you (as ‘extra_privacy’ in the wp_options table).

WordPress Plugins

Reader Interactions

Comments

  1. weston says

    June 17, 2010 at 7:35 pm

    AWESOME! I was just thinking about this the other day. I didn’t want to create my own options panel, just add it on to a current one. Awesome!

    Reply

Leave a Reply Cancel reply

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

Footer

My Books

I’m a front end developer at Equinox OLI, working on open source library software. I was previously a freelance WordPress developer in higher education. You can get in touch here or on LinkedIn.

Copyright © 2023 Stephanie Leary · Contact