Removing "Change Theme" Option From Customizer

Hi,

I wanted to remove the Change theme options from Customizer which was added in recent WordPress Update.

Please help.

  • Kasia Swiderska
    • Support nomad

    Hi CatMan,

    You need to add this code to functions.php file in your theme:

    function mycustom_customize_register( $wp_customize ) {
    $wp_customize->remove_section("themes");
    }
    add_action( 'customize_register', 'mycustom_customize_register' );

    This will remove Change theme option from Customizer.

    If you want to have this removed regardless to the used theme, you should put it into small plugin.

    Please let me know if this helpful information for you,

    kind regards,

    Kasia

  • CatMan
    • The Incredible Code Injector

    Hi,

    Can you tell me how to put this in a plugin? I want it as Must use plugin for my network since I don’t want “change theme” option in all sub-sites. Also, putting it in a plugin reduces work load during upgrades.

    Please help

  • Kasia Swiderska
    • Support nomad

    Hi CatMan,

    You need to make new PHP file, and at the start put plugin header, and after that code I previously showed. So I will look like that:

    <?php
    /*
    Plugin Name: Your plugin name
    Plugin URI: link to plugin site
    Description:
    Version: 0.1
    Author: CatMan
    Author URI: link to author site
    License: GNU GPL
    */
    function mycustom_customize_register( $wp_customize ) {
    $wp_customize->remove_section("themes");
    }
    add_action( 'customize_register', 'mycustom_customize_register' );

    And that is all. If you want to use it as Must Use plugin, remember that this plugin can not be in sub folder in mu-plugins folder.

    Please let me know how this works for you.

    kind regards,

    Kasia

  • Kasia Swiderska
    • Support nomad

    Hi CatMan,

    Can you see plugin on the plugins list – on your main site? If you use code in functions.php of your theme it works?

    Can you please change priority of add action to higher

    add_action( 'customize_register', 'mycustom_customize_register' , 15);

    and see if this works?

    kind regards,

    Kasia

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.