Best Practice to Remove WordPress Theme Editor Using add_action(): A Beginner Guide – WordPress Tutorial

By | May 23, 2020

When you are developing a wordpress theme, you may do not want users to edit your theme files. In this tutorial, we will introduce you how to do.

The theme editor looks like:

WordPress theme editor operation

We will use add_action() to implement this function, which will not edit wp-config.php file.

Some tutorials introduce a simple way to disable theme editor, for example, you can add code below in wp-config.php.

define('DISALLOW_FILE_EDIT', true );

Which is not a good way, we will use other method.

Open your theme functions.php and add code below:

function remove_submenu() {   
    remove_submenu_page( 'themes.php', 'theme-editor.php' );   

Then you will remove theme editor.

remove wordpress theme editor

Leave a Reply

Your email address will not be published. Required fields are marked *