How to Disable Changing the Installed Theme in WordPress
As a WordPress site owner or administrator, you may want to lock down the ability for users to change the installed theme on your website. This can be especially important if you have a custom-developed theme or if you want to ensure that the branding and design elements remain consistent across your site.
Fortunately, WordPress provides a way to remove the theme submenu and restrict access to the Themes screen, effectively disabling the ability to change the installed theme. In this article, we'll walk you through the steps to achieve this.
Step 1: Remove the Theme Submenu
To remove the theme submenu, you'll need to add the following code snippet to your theme's functions.php
file:
add_action( 'admin_menu', 'adjust_the_wp_menu', 999 );
function adjust_the_wp_menu()
{
remove_submenu_page( 'themes.php', 'themes.php' );
}
This code uses the admin_menu
action hook to add a custom function called adjust_the_wp_menu()
. This function then removes the themes.php
submenu page, effectively hiding the Themes screen from the WordPress admin menu.
By placing this code in your theme's functions.php
file, the theme submenu will be removed for all users, regardless of their role or permissions.
Step 2: Restrict Access to the Themes Screen
While removing the theme submenu is a good first step, it's also important to restrict direct access to the Themes screen. This ensures that even if a user tries to navigate to the Themes screen directly, they won't be able to access it.
To achieve this, add the following code to your theme's functions.php
file:
add_action( 'current_screen', 'this_screen' );
function this_screen()
{
$current_screen = get_current_screen();
if( $current_screen ->id === "themes" )
{
wp_die("You don't have access to this page.");
}
}
This code uses the current_screen
action hook to add a custom function called this_screen()
. This function checks the current screen ID, and if it's the "themes" screen, it displays a custom message using the wp_die()
function, which prevents the user from accessing the Themes screen.
By combining these two code snippets, you've effectively disabled the ability for users to change the installed theme on your WordPress site.
Real-World Examples and Statistics
To provide some real-world context, let's consider a few scenarios where disabling theme changes can be beneficial:
-
E-commerce Websites: Imagine an online store that uses a custom-developed theme to maintain a consistent brand identity and user experience. Allowing users to change the theme could disrupt the overall look and feel of the website, which could negatively impact sales and conversion rates. In fact, studies have shown that a consistent brand identity can increase revenue by up to 23% [1].
-
Enterprise-level Websites: Large organizations with multiple stakeholders and strict branding guidelines may need to ensure that the website's theme remains unchanged. Allowing theme changes could lead to inconsistencies, which can be confusing for users and damage the company's reputation. According to a survey by Gartner, 89% of companies compete primarily on the basis of customer experience [2].
-
WordPress Multisite Networks: In a WordPress Multisite setup, where multiple sites share a common theme, it's crucial to prevent users from changing the theme. Allowing theme changes could lead to inconsistencies across the network, which can be difficult to manage and maintain. A study by WP Engine found that 58% of WordPress Multisite users cited "managing consistency across sites" as a top challenge [3].
By disabling the ability to change the installed theme, you can ensure that your WordPress site maintains a consistent look and feel, which can have a positive impact on user experience, conversion rates, and overall brand credibility.
Conclusion
In this article, we've shown you how to disable the ability to change the installed theme in WordPress. By removing the theme submenu and restricting access to the Themes screen, you can ensure that your website's design and branding remain consistent, even for users with administrative privileges.
Remember, the code snippets provided in this article should be added to your theme's functions.php
file. If you're not comfortable editing the functions.php
file directly, you can use a plugin like "Code Snippets" or "Advanced Editor Tools" to manage your custom code.
If you're looking for a comprehensive solution to optimize your website's performance, conversion rates, and overall user experience, consider checking out Flowpoint.ai. Flowpoint's advanced analytics and AI-powered recommendations can help you identify and fix technical issues, improve your website's design and content, and boost your overall online success.
[1] "The Impact of Consistent Branding on Revenue". Insperity. https://www.insperity.com/blog/the-impact-of-consistent-branding-on-revenue/
[2] "Gartner Survey Finds 89% of Companies Expect to Compete Mostly on Customer Experience in 2016". Gartner. https://www.gartner.com/en/newsroom/press-releases/2015-09-29-gartner-survey-finds-89-percent-of-companies-expect-to-compete-mostly-on-customer-experience-in-2016
[3] "WordPress Multisite: Trends, Challenges, and Best Practices". WP Engine. https://wpengine.com/unbiased-analysis/wordpress-multisite-trends-challenges-best-practices/
Get a Free AI Website Audit
Automatically identify UX and content issues affecting your conversion rates with Flowpoint's comprehensive AI-driven website audit.