Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I would like to add additional options like footer text to the Twentyeleven options page via child theme. I know how to create theme option page but if possible I would like to use the one that comes with Twenty Eleven. If not how can I unhook this option page and create my own?

share|improve this question
    
you are much better of adding your own theme options page –  Bainternet Jul 9 '11 at 1:44

1 Answer 1

You can, but currently it's not easy. You would have to override the existing code, and re-write it to extend it with your additional options.

Start here:

add_action( 'admin_menu', 'twentyeleven_theme_options_add_page' );

You'd need to remove this action (in your Child Theme):

remove_action( 'admin_menu', 'twentyeleven_theme_options_add_page' );

Then, you would need to duplicate the twentyeleven_theme_options_add_page() function in your Child Theme:

function twentyeleven_child_theme_options_add_page() {
    $theme_page = add_theme_page(
        __( 'Theme Options', 'twentyeleven' ), // Name of page
        __( 'Theme Options', 'twentyeleven' ), // Label in menu
        'edit_theme_options',                  // Capability required
        'theme_options',                       // Menu slug, used to uniquely identify the page
        'twentyeleven_child_theme_options_render_page'            // Function that renders the options page
    );

    if ( ! $theme_page )
        return;

    $help = '<p>' . __( 'Some themes provide customization options that are grouped together on a Theme Options screen. If you change themes, options may change or disappear, as they are theme-specific. Your current theme, Twenty Eleven, provides the following Theme Options:', 'twentyeleven' ) . '</p>' .
            '<ol>' .
                '<li>' . __( '<strong>Color Scheme</strong>: You can choose a color palette of "Light" (light background with dark text) or "Dark" (dark background with light text) for your site.', 'twentyeleven' ) . '</li>' .
                '<li>' . __( '<strong>Link Color</strong>: You can choose the color used for text links on your site. You can enter the HTML color or hex code, or you can choose visually by clicking the "Select a Color" button to pick from a color wheel.', 'twentyeleven' ) . '</li>' .
                '<li>' . __( '<strong>Default Layout</strong>: You can choose if you want your site&#8217;s default layout to have a sidebar on the left, the right, or not at all.', 'twentyeleven' ) . '</li>' .
            '</ol>' .
            '<p>' . __( 'Remember to click "Save Changes" to save any changes you have made to the theme options.', 'twentyeleven' ) . '</p>' .
            '<p><strong>' . __( 'For more information:', 'twentyeleven' ) . '</strong></p>' .
            '<p>' . __( '<a href="http://codex.wordpress.org/Appearance_Theme_Options_Screen" target="_blank">Documentation on Theme Options</a>', 'twentyeleven' ) . '</p>' .
            '<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>', 'twentyeleven' ) . '</p>';

    add_contextual_help( $theme_page, $help );
}
add_action( 'admin_menu', 'twentyeleven_child_theme_options_add_page' );

Then, you would need to duplicate the theme_options_render_page() function in your Child Theme (e.g. as twentyeleven_child_theme_options_render_page()), adding in your additional Theme options.

Note that, hopefully, this will get much, much easier in a future version of Twenty Eleven. I'm getting ready to submit a patch to convert that theme_options_render_page() function to using add_settings_section() and add_settings_field() calls, rather than hard-coded table markup.

share|improve this answer

Your Answer

 
discard

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.