How To Add A Read More Link to Copied Text In WordPress

Friends, today we will talk about how to add a post read more link to the copied text in WordPress. If someone copies any type of text or even a single word from your website, then you can add the URL of your original post behind it if you have WhatsApp status website, for example, if you copy status quotes or Shayari from any blog/website, you will see that the post from which you copy status quotes or Shayari, you will paste that Shayari anywhere, then you will see the original link of that post.

So, friends, this function is using so which will keep the content of your website safe. If no one else does a copy, then the unique content will be maintained, then your website will rank quickly, so let’s see friends how to add a read more link to copied text in WordPress.

Read Also – Amazon Great Indian Sale Started From 18th January 2020

Step-1

First, you have to log in to your website and open Simple Dashboard.

Step-2

After the dashboard is open, you have to go to the theme editor in the appearance at the option on the right side.

How To Add A Read More Link to Copied Text In WordPress
How To Add A Read More Link to Copied Text In WordPress

Step-3

Inside the theme editor, you have to see the name function.php and open function.php .

How To Add A Read More Link to Copied Text In WordPress
How To Add A Read More Link to Copied Text In WordPress

Step-4

After opening the function.php, you have to go to the bottom of the function.php and now copy the code below and go to the bottom of the function.php and paste it. After the paste, you have to click on the update file.

Code-

function add_copyright_text() {
if (is_single()) { ?>
<script type='text/javascript'>
function addLink() {
var selection = window.getSelection();
var htmlDiv = document.createElement("div");
for (var i = 0; i < selection.rangeCount; ++i) {
htmlDiv.appendChild(selection.getRangeAt(i).cloneContents());
}
var selectionHTML = htmlDiv.innerHTML;
var pagelink = "<br/><br/>Read more: <a href='"+document.location.href+"'>"+document.location.href+"</a>";
var copytext = selectionHTML + pagelink;
var newdiv = document.createElement('div');
newdiv.style.position = 'absolute';
newdiv.style.left = '-99999px';
document.body.appendChild(newdiv);
newdiv.innerHTML = copytext;
selection.selectAllChildren(newdiv);
window.setTimeout(function () { document.body.removeChild(newdiv); }, 0);
}
document.oncopy = addLink
</script>
<?php
}
}
add_action( 'wp_head', 'add_copyright_text');

Step-5

After the file is saved, now anyone will copy the content or single word from your website, then it will automatically get a link to your original post.

So friends, in this post we talked about How To Add A Read More Link to Copied Text In WordPress. So, friends, you should do this immediately on your website and share it with your friends and tell them. So friends if you like this post so please share it with your friends and social media. To get an interesting post like this, subscribe to the newsletter of our website so that whenever we will publish any new tips or new posts, then the link will reach to you. Thank You For Visiting Our Website.

You Can Read Also

Spread the love

Leave a Comment