Alex Wells website developer logo

Main menu

  • Home
  • Blog
    • Tutorials
    • Bookmarks
    • Website Q&A
    • Submit a Question
  • Web Development
    • Website Projects
    • WordPress
    • Portfolio
  • About me
    • Pinterest
  • Contact me
    • Website review
Follow Alex Wells on Twitter connect with Alex Wells on LinkedIn alex-wells.co.uk rss feed

Home > Add copy write notice when people copy text from your website

Post navigation

← How to find industry news to blog about
Google Analytics – what can I do about not provided search terms? →

Add copy write notice when people copy text from your website

Posted on June 12, 2012 by Alex Wells

This handy bit of code will add a copy write notice to your text when people copy it from your website, this code is for wordpress but could be adapted to fit other platforms, to add this code to your wordpress website add the following code into your themes functions.php file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function add_copyright_text() { ?>

<script type='text/javascript'>
function addLink() {
var body_element = document.getElementsByTagName('body')[0];
var selection;
selection = window.getSelection();
var pagelink = "<br /><br /> Read more at Alex-wells.co.uk: <?php if(is_single()){ the_title();}?> <a href='"+document.location.href+"'>"+document.location.href+"</a>"; //Change this if you like
var copy_text = selection + pagelink;
var new_div = document.createElement('div');
new_div.style.left='-99999px';
new_div.style.position='absolute';

body_element.appendChild(new_div );
new_div.innerHTML = copy_text ;
selection.selectAllChildren(new_div );
window.setTimeout(function() {
body_element.removeChild(new_div );
},0);
}

document.oncopy = addLink;
</script>

<?php
}

add_action( 'wp_head', 'add_copyright_text');

 

Example of the outcome when pasted into a word document:

Copy Write added to content copied from a word press blog

Need help installing this script on your website? contact me for any website development queries

I have installed the code on this website, but am not sure if i will keep it. The code is handy for adding a copy write notice but it is not always suitable – on this site i post allot of website development code (the above for example) and the script will add a copy write notice to this as well which could cause problems if people do not remove the code.

All in all its a handy bit of code that even if i dont use on this website i can see its application on others so thought I would share.

source: http://www.wpbeginner.com/wp-tutorials/how-to-add-a-read-more-link-to-copied-text-in-wordpress/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+wpbeginner+%28WordPress+for+Beginners%29

 


Alex Wells Blog Post

Blog post by Alex Wells
Working as a Website developer I love nothing more then working waist deep in code, I have specific interests in PHP and WordPress development but mostly working with local businesses to provide them with a website that meets their needs. Contact me if you have a project in mind and would like to get an input from an experienced website developer.
Find Alex Wells on Twitter Alex Wells on LinkedIn Alex Wells on Google Alex Wells RSS feed

This entry was posted in Blog, code. Bookmark the permalink.
->Share this post on Twitter

Post navigation

← How to find industry news to blog about
Google Analytics – what can I do about not provided search terms? →

Leave a Reply Cancel reply

Share this page

My Projects

Owlmarks.com

Web developer at

Website design bishops stortford

Twitter


alex-wells.co.uk RSS feed

Categories

  • Blog
  • Bookmarks
  • code
  • home
  • noPic
  • portfolio
  • Tutorials
  • Website Q&A
  • WordPress

Website Information

Cookie Policy
Blog Post List

Archives

  • May 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011

Recent Posts

  • First impressions count – what does your website say about you?
  • Reduce the cost of a new website / redesign
  • Just how easy is it to update your own WordPress website?
  • The ongoing process of running a website
  • How to write good content

Contact me

info@alex-wells.co.uk
@alex_simpsons

Pages

  • About me
  • Alex-Wells.co.uk Blog Post List
  • Contact me
  • Cookie Policy
  • Pinterest
  • Portfolio
  • Submit a Question
  • Web Development
  • Website Projects
  • Website review

Share this page

58 queries in 0.444 seconds.
© Alex Wells 2013