How to Prevent Text Selection and Copy/Paste in WordPress

 How to Prevent Text Selection and Copy/Paste in WordPress

So we will now learn two ways to prevent copying of articles and WordPress site content

One of the things that cause inconvenience sometimes, when you spend long hours creating the content of your site, and then people come to steal this content from your site to their site, and because sometimes search engines overlook the copied content, perhaps the content will appear on the copied site before the content of your site

  • The first method is using the add
  • The second method is using the code

Prevent copying of articles in WordPress

There are many WordPress plugins that you can rely on completely to grant copying of articles and content, but we will now explain the best plugin we recommend using and it is called WP Content Copy Protection & No Right Click

With this plugin we protect articles, WordPress site content and posts from being copied by anyone. It is a free addon that you are free to use

See the following video to install the extension and install its settingsPrevent copying of articles and WordPress site content

Other plugins can also be relied upon for the purpose of preventing copying of articles in WordPress

Prevent copying WordPress content without plugin

In this method, we will use two codes, the first Css and the second Javascripts, the first to prevent text selection and copying, and the second to prevent right-clicking on the site’s content … but only for visitors and not for the admin .. As for the properties of copying the content to the admin on the site, it will remain fully enabled.

Go to the functions.php file in the theme file if you are going to modify the theme or if you are working on a theme, and paste the following code:

function wpmrj3_prevent_text_copy(){
if ( is_user_logged_in() ) {
    echo '';
} 
else {
 echo'
 <style type="text/css"> 
    html,
    body.wp-admin {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -youbkit-touch-callout: none; 
    -youbkit-user-select: none;  
    -moz-user-select: none;    
    -ms-user-select: none;      
    user-select: none;      
 }</style>' ; 
} }
add_action('wp_head','wpmrj3_prevent_text_copy');

As for the second code, it is the javascript code, search in the theme for javascript files that have the extension .js

After you found the js file in the theme, or if you created a new javascript file and called it in the functions.php file, paste the following code in the javascript file you created

document. oncontextmenu = new Function ( "alert('This property is disabled on our site'); return false" ) ; 

Conclusion :

There are many ways to give copy content but what matters to you in the end is that the feature works well on your site. You can always get solutions for all the ideas or problems you may have, and I can help too. Just leave me a comment and I will answer you with the appropriate solution