|
↳ See all 15 articles
/ Documentation /Theme Customization/ How To Disable Right Click in WordPress

How To Disable Right Click in WordPress

Are you concerned about your website’s content or images being misused? It’s easy for users to copy, save, or hot-link your images, especially on content-rich sites like photography portfolios.

One effective method to help safeguard your content is to disable the right-click option, preventing unauthorized use of your images.

In this document, we’ll explore why you might want to disable the right-click function in WordPress. Additionally, we’ll walk you through three simple methods to safeguard your valuable content.

When to Consider Disabling Right Click in WordPress

Consider disabling right-click if your WordPress site features unique content, especially images. This action can help prevent content theft and discourage image hotlinking, which strains your server and breaches copyright.

However, be aware that disabling right-click can impact user experience, especially for sites where users frequently copy content, like recipes or DIY guides. Additionally, this method isn’t foolproof; savvy users can bypass it through various techniques.

How To Disable Right Click in WordPress

Now that you know how disabling right-click can protect the content on your website. Here are some ways you can use to disable the right click on your website.

Use Astra Site Builder to Disable Right-Click

You can disable the right-click feature by inserting JS code into your footer.php file using the Site Builder module of Astra Pro. Using the Site Builder module, you can create a hooks layout and add the code shared below.

Before proceeding, ensure you have the Astra theme and Astra Pro Addon plugin installed and activated on your website.

<script type="text/javascript">
jQuery(document).ready(function ($) {
    // Disable cut/copy/paste
    jQuery('body').on('cut copy paste', function (e) {
        e.preventDefault();
    });
    // Disable right-click context menu
    jQuery('body').on('contextmenu', function (e) {
        e.preventDefault();
        return false;
    });
});
</script>

Once installed, navigate to Astra > Site Builder and create a hooks layout with Code Editor to add the code. Check this guide to learn more about using the Site Builder Hooks.

image

With this code in place, users will be unable to right-click on the pages of your website.

It’s straightforward, right? Go ahead and give it a try.

You can also try the alternate option shared below by using a plugin to disable the right click.

Use the WP Content Copy Protection & No Right Click Plugin

By using the WP Content Copy Protection & No Right Click plugin, you can prevent right-click actions in WordPress and disable commands like CTRL+C.

This plugin goes a step further by disabling CTRL+U in Chrome, preventing users from viewing your page code, which is another method of content theft.

Moreover, you can extend protection beyond images by disabling the ability to select text. Upgrading to the premium version unlocks additional features, such as watermarking and jQuery overlay protection.

To begin, you’ll need to install and activate the plugin in your WordPress.

Once it’s activated and running on your site, navigate to Copy Protection > Settings. Under Main Settings, you can enable protection on your homepage, posts, and more.

When you’re ready, save your settings. You can then test these changes on the front end.

For instance, you might see a warning message when you try to select or copy an image.

We hope the above information has been helpful to disable the right click on your website. If you have any questions or need help setting up the Site Builder layout for this, please do not hesitate to reach out to our support team.

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
Scroll to Top