How to Disable Right Mouse Click on Your Entire WordPress Website

Disable right click in WordPress to protect your content from being easily copied by visitors.

Disabling right mouse click on your website can help protect your content from being easily copied by visitors. In this post, we’ll show you how to add a small piece of code to your functions.php file to disable right-click across your entire WordPress site.

Step-by-Step Guide:

  1. Access Your WordPress Dashboard
    • Log in to your WordPress admin area.
  2. Navigate to Theme Editor
    • From the dashboard, go to Appearance > Theme Editor.
  3. Open functions.php File
    • In the Theme Files section on the right, locate and click on functions.php. This file controls the functions of your WordPress theme.
  4. Add the Code to Disable Right-Click
    • Scroll to the bottom of the functions.php file and add the following code snippet:
function disable_right_click() {
     echo "<script type='text/javascript'>
     document.addEventListener('contextmenu', function(event) {
     event.preventDefault();
     });
    </script>
     ";
     }
add_action('wp_head', 'disable_right_click');


Save Your Changes

After adding the code, click the Update File button to save your changes.
Test Your Website

Visit your website and try right-clicking to ensure that the context menu is disabled.
Note: While disabling right-click can deter casual users from copying your content, it is not a foolproof method. Users with technical knowledge can still access your source code and images. Use this method as part of a broader strategy to protect your content.

share this recipe:
Facebook
Twitter
Pinterest

Still hungry? Here’s more

IP-v6

Discover the power of IP v6 with our comprehensive tools designed just for you! Whether you’re looking to convert, validate, or calculate subnet information, our IP v6 Converter and Validator are here to simplify your networking tasks. Dive deeper into the world of IPv6 with our educational content, tailored to enhance your understanding and skills. Join us on this journey to master the next generation of internet protocol and unlock the potential of your network. Don’t miss out on the opportunity to elevate your expertise—explore our resources and become an IPv6 pro today!

Read More