Are you afraid of Content Thieves or your WordPress blog has a lot of copyrighted images and you don’t want just people to copy content. Believe me there is no full proof way to stop stealing stuff, however you can still lock the doors for people. Doesn’t Amaze you ? Here check out this tutorial to disable right click on website.
You must have tried your luck with a lot JavaScript solutions and plugins, but they didn’t work with your WordPress Blog. Hmmm! Don’t worry, follow this 2-step thesis tutorial to disable right click on WP blog:
Step1: Update WordPress & Thesis Theme
Before we go ahead with the tutorial, its recommended to update latest version of WordPress and Thesis Theme. Don’t know how to do that ? Well, it is simple, refer to article Safely upgrade to latest version Thesis 1.8 ?
Already updated? Go to Step2.
Step2: JavaScript Code to Protect Content
Below is the working JS code to disable right click on WordPress blog. Add the code snippet in custom_functions.php in Thesis Theme.
NOTE: Make sure you take full backup of custom_functions.php file using FTP before modifying it or you can also refer to the article about how to safely edit custom_functions.php
/* TheCreatology Tutorial - Disable Right Click Author: Aky Joe Email: help@thecreatology.com */ function joe_disable_right_click(){ ?> <script language="Javascript"> /*<![CDATA[*/ document.oncontextmenu = function(){return false;}; /*]]>*/ </script> <script type="text/javascript"> /*<![CDATA[*/ document.onselectstart=function(){ if (event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type != "password") { return false; } else { return true; } }; if (window.sidebar) { document.onmousedown=function(e){ var obj=e.target; if (obj.tagName.toUpperCase() == "INPUT" || obj.tagName.toUpperCase() == "TEXTAREA" || obj.tagName.toUpperCase() == "PASSWORD") { return true; } else { return false; } }; } /*]]>*/ </script> <script type="text/javascript" language="JavaScript1.1"> /*<![CDATA[*/ if (parent.frames.length > 0) { top.location.replace(document.location); } /*]]>*/ </script> <script language="Javascript"> /*<![CDATA[*/ document.ondragstart = function(){return false;}; /*]]>*/ </script> <?php } add_action( 'wp_head', 'joe_disable_right_click' );
Done adding above code? Save the custom_functions.php file and upload it to server using FTP. The above code will not only disable right click but will also disable highlight text on WordPress Blog.
Disable Right Click Demo
I hope you are not waiting for some fireworks, TRY TO RIGHT CLICK anywhere on your WordPress Page. 😉
Are we done ?
Yes, I hope the above demo made your mind.
One of my client’s requirement was to disable right click only on single posts. In such cases, you can use WordPress Conditional Tags with Code above in Step2.
With this we come to end of this article to disable right click to protect content copying on WordPress blog using Thesis Theme. If you have any query or further assistance is required, post feedback as comment below.