How to Disable Right Click on WordPress Without Plugin
Blogging is the best way to share your ideas with the world. But what if you’ve been working hard and putting a lot of time into writing, and someone else is copying your content easily? If that happens you probably won’t know what to do.
Some website owners get around this problem by disabling the right-click or copy-paste functionality.
In this article, we will show you how to disable right-click in WordPress without plugin.
Disable WordPress Right Click Without Plugin
In this method, you need to paste the following code into the WordPress theme file. First, all you have to do is login to the admin dashboard, and in the left pane go to Appearance > Theme Editor.
Now, on the right menu select the header.php file to add the following code to the header section of your website.
Then, add the following code before the
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if((eventbutton==2)||(eventbutton==3)) return false;
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
Then save the header.php file by clicking the Update File button, and clear the cache to load the script. The above code will prevent right click on every page on your website. So that visitors can not perform the function of right-click or copy-paste.
If having trouble to disable right click using code. You can check out our article on how to disable right-click in WordPress using a plugin.
Should You Disable Right Clicks?
Disabling right-click can protect your content from being copied. But nothing can stop those who are already pros at copying any content.
They can copy anything from a web page or website because everyone has their own method of doing it, even if you use any plugins or scripts on your site.
If the above method can protect content piracy, then every developer will use this method.
We hope this article helped you learn how to disable right-click on your WordPress site