Take the 2-minute tour ×

I followed the Settings API page and used the example to get the following code: http://pastebin.com/CUA7nLCR

When I change $settingsPage to general, reading, writing, etc. this all works flawlessly but when I change it to permalink it does show up, but it will not store the value. Does anyone know why?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I ran into this very same issue and I have a workaround. Hopefully it will be fixed in the upcoming 3.3 release as this trac ticket suggests.

The workaround basically replicates the important bits of the wp-admin/options.php file where settings registered via the settings API are processed.

The reason additional permalink settings do not currently update is because the options-permalink.php page posts back to itself rather than to options.php so no handling of your registered settings occurs.

The following code placed in your theme or plugin will get things working:

// add a very low priority action to make sure any extra settings have been added to the global
add_action( 'admin_init', 'enable_permalink_settings', 999999 );
function enable_permalink_settings() {
    global $new_whitelist_options;

    // save hook for permalinks page
    if ( isset( $_POST['permalink_structure'] ) || isset( $_POST['category_base'] ) ) {

        $option_page = 'permalink';

        $capability = 'manage_options';
        $capability = apply_filters( "option_page_capability_{$option_page}", $capability );

        if ( !current_user_can( $capability ) )
            wp_die(__('Cheatin&#8217; uh?'));

        // get extra permalink options
        $options = $new_whitelist_options[ $option_page ];

        if ( $options ) {
            foreach ( $options as $option ) {
                $option = trim($option);
                $value = null;
                if ( isset($_POST[$option]) )
                    $value = $_POST[$option];
                if ( !is_array($value) )
                    $value = trim($value);
                $value = stripslashes_deep($value);
                update_option($option, $value);

         *  Handle settings errors
        set_transient('settings_errors', get_settings_errors(), 30);
share|improve this answer
Probably not in 3.3. Settings reorg got punted to 3.4. –  Otto Sep 27 '11 at 19:11
@otto Ah ok. Guess I'll be keeping this snippet around for a while longer then! –  sanchothefat Sep 28 '11 at 9:06

Your Answer


