WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Child theme code for removing background and header (6 posts)

  1. Eric
    Member
    Posted 1 year ago #

    I am creating a child theme for Twentytwelve as the parent.

    I want to remove the Dashboard options to change the header and background.

    I managed to come up with the following code, it doesn't crash the site, and it accomplishes what I intended without breaking anything (that I have discovered so far) but I want to make sure I am writing the code properly.

    What is the correct way to write the following?

    <?php
    
    function twentytwelvechild_remove_custom_appearance() {
    remove_theme_support( 'custom-background' );
    remove_theme_support( 'custom-header' );
    }
    add_action( 'after_setup_theme', 'twentytwelvechild_remove_custom_appearance', 11 );
    
    ?>

    That is the entire contents of my child's functions.php

  2. NoahB
    Member
    Posted 1 year ago #

    Your PHP looks all right to me! What are you asking (more specifically)?

  3. esmi
    Forum Moderator
    Posted 1 year ago #

    I can't see anything wrong with the above code. :-)

  4. Eric
    Member
    Posted 1 year ago #

    Oh, I thought it might be wrong to repeat

    remove_theme_support

    When I try

    remove_theme_support(  'custom-background', 'custom-header'  );

    It either breaks or the header removing doesn't work.

    Shouldn't I just have to write that once and be able to put both the background and header things in there?

    I guess if it doesn't break anything, and it doesn't appear to be, it doesn't matter.

    Thanks to you both.

  5. NoahB
    Member
    Posted 1 year ago #

    Nope. It's correct AFAIK. Happy coding!

  6. Eric
    Member
    Posted 1 year ago #

    Thanks again

Topic Closed

This topic has been closed to new replies.

About this Topic