• Resolved larsejaas

    (@larsejaas)


    I am using my own Headless WordPress theme with a decoupled frontend. However, I am unsure how to disable/hide the
    ‘customizer’ menu entry under Appearance? The theme developer handbook or documentation doesn’t really help me much here. I was under the impression that the menu entry would be hidden when the theme is a block theme.
    Is it possible to remove the menu using the remove_submenu_page method, inside the themes functions.php file? I have tried this approach – however, I can’t seem to get this working.
    I only really only use the Gutenberg/block editor and do not need the customizer menu.
    https://i.imgur.com/am3hkR3.png

    • This topic was modified 1 year, 7 months ago by larsejaas.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi, this code worked for me (in an mu-plugin):

    <?php
    
    namespace TrunkDev\MU_Plugins\Temporary;
    
    add_action( 'admin_menu', __NAMESPACE__ . '\remove_customizer' );
    
    function remove_customizer() {
    	$customize_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' );
    	remove_submenu_page( 'themes.php', $customize_url );
    }
    

    Just passing customize.php to remove_submenu_page() won’t work, because that’s not the exact URL that gets added to the menu.

    Moderator bcworkz

    (@bcworkz)

    I was under the impression that the menu entry would be hidden when the theme is a block theme.

    FYI, that is true; however, if any theme or plugin adds a callback to “customize_register” action the customizer will reappear.

    Thread Starter larsejaas

    (@larsejaas)

    @iandunn – will try your approach: Definitely wouldn’t have figured this one out myself – thanks ??
    @bcworkz Thanks for clarifying: I probably have a callback or function that causes this ??

    Thread Starter larsejaas

    (@larsejaas)

    Thanks again @iandunn – I added the code you proposed to my own custom plugin as I didn’t seem to be able to get it working in my theme. Not that it is super important. Thanks! This was exactly what I was after ??

    Glad to hear it ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to remove the customizer menu entry’ is closed to new replies.