Categories
Software Development

A simple way to add copyright notice to your website’s footer that you never have to update again

As I had to add a copyright notice to my WordPress website I wondered how should I automate it in a way that I never have to worry about again.

It is a really simple task, but still, since I was going to add it as an html widget I didn’t want to break the code with PHP. In case of an error I could loose a lot of time fixing the error.

That is why I thought. Ok, JavaScript is my best friend in the web world. It is a no-brainer task.

You do not have to worry about breaking the code.

You can copy this code from  below and you never have to manually update it again.

<div>
  Your company name &copy; 2016 - <span id="botondev-currYear"></span>
</div>

<script>
  jQuery(function(){
    jQuery("#botondev-currYear").html(newDate().getFullYear());
  });
</script>

 

If you are using WordPress too, you have to make sure to use the “jQuery” word instead of the “$” sign since it is preserved for PHP .

If in any case you would like to try this code on a webpage that has no jQuery included, you might want to use this code instead

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div>
 Your company name &copy; 2016 - <span id="botondev-currYear"></span>
</div>

<script>
 jQuery(function(){
 jQuery("#botondev-currYear").html(newDate().getFullYear());
 });
</script>

I hope it helps. Let me know if you have any question or suggestion.

By Botond Bertalan

I love programming and architecting code that solves real business problems and gives value for the end-user.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.