Stephanie Leary

Writer and WordPress consultant

  • Books
    • Content Strategy for WordPress (2015)
    • WordPress for Web Developers (2013)
    • Beginning WordPress 3 (2010)
  • Blog
    • Fascism Watch (2016-17)
    • Content Modeling for WordPress series
    • WordPress Hidden Gems series
  • Work
    • Portfolio
    • Services
    • WordPress Plugins
    • WordPress Themes
    • Presentations and Interviews
    • on GitHub →
  • About
    • Press Kit
  • Contact
    • Mailing List

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

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 *

Fascism Watch

The Fascism Watch is a daily(ish) news roundup. View all the previous Fascism Watch posts »

Latest WordPress Book

Content Strategy for WordPress

A short book for content strategists and managers on implementing a complete content strategy in WordPress: evaluation, analysis, content modeling, editing and workflows, and long-term planning and maintenance.

Read the sample chapter

Kindle Nook iBooks Kobo Smashwords

WordPress for Web Developers

WordPress for Web Developers (9781430258667)

This is a book for professional web designers and developers who already know HTML and CSS, and want to learn to build sites with WordPress. The book begins with a detailed tour of the administration screens and settings, then digs into server-side topics like performance and security. The second half of the book is devoted to development: learning to build WordPress themes and plugins.

This is the second, much-revised and updated edition of Beginning WordPress 3, with a more accurate title. Everything’s been updated for WordPress 3.6.

WordPress for Web Developers is out now. See what's inside...

The best WordPress features you’ve never noticed

  • WordPress Hidden Gems: Screen Options
  • WordPress Hidden Gems: Bulk Edit
  • WordPress Hidden Gems: Private Status
  • WordPress Hidden Gems: Dashboard Feed Readers
  • WordPress Hidden Gems: Options.php

Content Modeling for WordPress series

  • Content modeling for WordPress, part 1: analyze content
  • Content modeling for WordPress, part 2: functional and organizational requirements
  • Content modeling for WordPress, part 3: a sample content model

This is an excerpt from Content Strategy for WordPress.My latest books are Content Strategy for WordPress (2015) and WordPress for Web Developers (2013). Sign up to be notified when I have a new book for you.

Copyright © 2021 Stephanie Leary