A great way to protect your content is to insert a link to a WordPress source. We figure out what we need to do and how to do it correctly.

Why do I need to add a link when copying?

This is one of the methods to make sure that the content of the site is not stolen. Unique content costs money. It’s a shame when it is stolen and placed for free without the consent of the author on another resource. As a result, it is hard to prove that you wrote this text.

But you can make it difficult for the “copoupaster” to work. This automatically adds a permanent link to the source page if you want to copy the text of the publication.

How do I insert a link to a source when copying text in WordPress?

Let’s look at the working methods of content protection. They differ in the implementation method, but give the same result. They work for all records, pages and widgets.

Append Link on Copy plugin

After installation and activation, in the admin panel, go to Settings > Append Link on Copy, where the Read more link option: (like: Text copied from %link% ) enter the text of the future external link.

Don’t forget to click the Save changes button.

File functions.php

Add a PHP script at the very end of the file:

function wpschool_add_copy_link() {
    if ( !current_user_can( 'manage_options' ) ) {    
        $source_text = __( '<br><br>Text copied from: %link%' );
        $source_text = str_replace('"', '\"', $source_text);
        echo '<script>';
        echo 'document.oncopy = function () {';
        echo 'var bodyElement = document.body;';
        echo 'var selection = getSelection();';
        echo 'var link_url = document.URL;';
        echo 'var page_link = "' . $source_text . '";';
        echo 'page_link = page_link.replace("%link%", " " + link_url + " ");';
        echo 'var copy_text = selection + page_link;';
        echo 'var divElement = document.createElement("div");';
        echo 'divElement.style.position="absolute";';
        echo 'divElement.style.left="-99999px";';
        echo 'bodyElement.appendChild(divElement);';
        echo 'divElement.innerHTML = copy_text;';
        echo 'selection.selectAllChildren(divElement);';
        echo 'window.setTimeout(function() {';
        echo 'bodyElement.removeChild(divElement);';
        echo '},0);';
        echo '}';
        echo '</script>';
add_action( 'wp_footer', 'wpschool_add_copy_link' );