How to Disable Right Mouse Click on Your Entire WordPress Website

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.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

More post