I am adding an option field to the 'general options' page in WordPress. I cannot get WordPress to save the field. Cannot figure out what I am doing wrong.

function add_banner_options() {
    register_setting( 'home_banner_group', 'home_banner' );
    add_settings_field( 'home_banner', 'Home Banner', 'banner_callback', 'general' );
add_action( 'admin_init', 'add_banner_options' );

function banner_callback( $args ) {
    $val = get_option( 'home_banner' );
    <input id="home_banner" type="text" class="regular-text" name="home_banner" value="<?php echo $val; ?>"/>

In the codex the group is implied to be unique. However, since I am adding this field to the general options menu, it is in fact this group I must use.

 register_setting( 'general', 'home_banner' );

Your Answer

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

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