How To Add a Read More Link to Copied Text in WordPress

Subscribe our YouTube Channel    

How To Add a Read More Link to Copied Text in WordPress | Hello dosto aapka swagat hai aajke yah fresh article mai, aaj mai aapko sikhaunga ki kis tarah se aap aapne wordpress website mai read more at ka link add kar sakte hai.

Note: Maine yah function abhi es site mai se remove kardiya hai, apko yaha se code copy and paste karne mai koy problem na ho esiliye.

Agar visitor aapke site mai se ek text, word ya pura paragraph copy karenge to jaha par wo text ko peast karenge waha automatic last mai aapki site ka original link show hoga, aap nice ek image hai esmai dekh sakte hai.

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 at BM Tech: <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');

Agar aapko yah article pasand aaya to share jarur kijiyega sabhi social media me, or ha ek request hai hamare youtube channel ko jarur Subscribe karna ,aap hume sabhi social media pe bhi follow karlijiye jaise ki, Facebook, Twitter, Instagram, YouTube.

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

Bharat Makwana is a Founder & Owner of Veewom. He is Content creator and Web Developer from past three years. He loves to read and get in touch with the latest technology, he also have YouTube Channel BMTechTips ,for more info contact - hi@bharatmakwana.com.

You may also like this!