How to disable right click and Text Selection in WordPress

default single post image

It is very common to watch that some bloody spammer keep on copy pasting your important article on their website and, Since your countries cyber Law is not applicable on them.  These spammers even does not care to change your links.

They simply copy paste your article, to disable right click and selection of your text, there are WordPress plugin but as, We hate adding every next Plugin, We love to hack the system.  Here is my hack to do this.

Open your functions.php file and add the following code in it. This will prevent right click on your website. ( Here we are assuming that you are loading jquery as per the requirement)


function disable_right_click(){ ?>

//// Disable right click
jQuery(document).bind(‘contextmenu’, function (e) {
// alert(‘Right Click is not allowed’);

<?php }

add_action( ‘wp_footer’, ‘disable_right_click’ );


Now its time to disable selection of text using mouse or keyboard. The trick is very simple, again open your style.css file and copy paste the following code.


body {
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
user-select: none; }


Now save your work and enjoy.

Related Posts

Leave a Reply

Your email address will not be published.