WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to add a field to the general settings page, but I can not save the field because I can't find a hook for the pages save.

Any ideas?

share|improve this question
up vote 5 down vote accepted

You just need to register_setting() on your setting and it will be saved automatically. See the Settings API for more info. Here's a complete example:

function spw_cb() {
    if( !($value = get_option('sprockets_per_widget')) ) {
        $value = 7;

    <input type="text" size="3" name="sprockets_per_widget" value="<?php echo $value; ?>" /> Numeric only!

function spw_init() {
    add_settings_field('sprockets_per_widget', 'Sprockets per Widget', 'spw_cb', 'general');
    register_setting('general', 'sprockets_per_widget', 'intval');
add_action('admin_init', 'spw_init');
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.