WordPress.org

Forums

[resolved] Remove header and background option pages in twenty eleven child theme (11 posts)

  1. Vayu Robins
    Member
    Posted 3 years ago #

    Hi.

    I am creating a child theme based on the Twentyeleven theme. I have no use of the two settings pages that Twentyeleven adds to the admin menu, namely Header (themes.php?page=custom-header) and Backgound (themes.php?page=custom-background). Therefor I would like to somehow deactivate or remove them.

    I have searched the net for a solution, but can't find any. How can I do this?

    Hope someone can help. :-)

    Vayu

  2. dbaron
    Member
    Posted 3 years ago #

    There may be a better way to do this, but here is how I go about it. Open your functions.php file and comment out the commands that generate the link you want to remove.

    To remove the Header link, comment out this line:
    add_custom_image_header( 'twentyeleven_header_style', 'twentyeleven_admin_header_style', 'twentyeleven_admin_header_image' );

    To remove the Background link, comment out this line:
    add_custom_background();

    To remove the Theme Options link. comment out this line:
    require( get_template_directory() . '/inc/theme-options.php' );

    I always keep the Widgets and Menus link, so I don't know about those. I hope this helps.

  3. Vayu Robins
    Member
    Posted 3 years ago #

    Hi dbaron.

    Thank you for your tips. :-) I was, however, aware of this solution, but as I am doing a child theme, I would rather not have to edit anything in the parent theme files.

    But maybe there is no other way of doing this?

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    Child theme's functions.php:

    remove_custom_image_header();
    remove_custom_background;
  5. Vayu Robins
    Member
    Posted 3 years ago #

    Hi Esmi.

    Thank you for chipping in. :-) This is not working for when I call those 2 function directly in the functions.php file, but I got it working like this:

    add_action( 'after_setup_theme','remove_twentyeleven_options', 100 );
    function remove_twentyeleven_options() {
    
    	remove_custom_background();
    	remove_custom_image_header();
    
    }

    Again, thank you guys for helping out, I appreciate it very much. :-)
    Vayu

  6. WebAuthor5555
    Member
    Posted 3 years ago #

    How would I modify that last solution if I want to eliminate just the background area around the page? I'm trying to get the page to fill the browser page.
    Any ideas???

  7. the last solution only applies to the background css properties such as background color or background image - for your question you will need to edit the style.css in your child theme of Twenty Eleven and change the properties of the #page style (as far as i remember).

    please post a link to your site.

  8. Vayu Robins
    Member
    Posted 3 years ago #

    Hi WebAuthor5555.

    To me it sounds like your on to something different than what this post is about. Forgive me if I have misunderstood your question, but for that you just wanna change the stylesheet, which is not easily explained here. :-)

  9. WebAuthor5555
    Member
    Posted 3 years ago #

    Well, some progress.
    Was able to get the top margin and the left margin to shift to where I want them by adding this to the child theme style sheet:

    /* =Structure
    ----------------------------------------------- */

    body {
    padding: 0;
    }
    #page {
    margin-top:0;
    margin-bottom:0;
    margin-right:0;
    margin-left:0;
    max-width: 960px;
    }

    /* One column */
    .one-column #page {
    max-width: 960px;
    }
    ===================================
    However, the page shifted to the left, leaving the right margin twice as large as it was.

  10. WebAuthor5555
    Member
    Posted 3 years ago #

    It works! Just changed the 960px settings to 1040px and it all fell into place. I ran my video from 800x600 through 1152x860 and it held its own.

    Thanks to you all.

  11. yammez
    Member
    Posted 3 years ago #

    If you want to get rid of the Theme Options page for Twenty Eleven you can use that code posted by Vayu and add this line:

    remove_action('admin_menu', 'twentyeleven_theme_options_add_page');

    So the whole thing:

    //Remove the custom options provided by the default twentyeleven theme.
    add_action( 'after_setup_theme','remove_twentyeleven_options', 100 );
    function remove_twentyeleven_options() {
    
    	remove_custom_background();
    	remove_custom_image_header();
    	remove_action('admin_menu', 'twentyeleven_theme_options_add_page');
    
    }

Topic Closed

This topic has been closed to new replies.

About this Topic