Your website is your reflection to the online world. It’s responsible for the impression you want to give your audience. Some common mistakes can ruin your persona. An outdated copyright date is one of the common mistakes that most of the webmasters do.
An outdated copyright date or an expired offering calls all the information on a website into question as to its correctness.
4 ways to Add a Dynamic Copyright Date
-
Simple PHP method
This is the simplest method for showing dynamic copyright date in your website. Just put this code in your PHP file and show the current year in your website.
Copyright <?php echo date('Y'); ?> My Company.
-
JavaScript Method
This is an another simplest method for showing dynamic copyright date in your website. Just use this JavaScript code and show the current year in your website.
var theYear = document.createElement( 'div' ); theYear.classList.add( 'the-year' ); theYear.textContent = 'Copyright ' + new Date().getFullYear() + ' My Company.'; document.body.appendChild( theYear );
Source: GitHub
-
From Year to current Year
If you want something more elaborate that will take the year of the earliest post you have to the latest post you have, you can do this by adding the following function in your functions.php file.
function smallenvelop_copyright() { global $wpdb; $copyright_dates = $wpdb->get_results(" SELECT YEAR(min(post_date_gmt)) AS firstdate, YEAR(max(post_date_gmt)) AS lastdate FROM $wpdb->posts WHERE post_status = 'publish' "); $output = ''; if($copyright_dates) { $copyright = "© " . $copyright_dates[0]->firstdate; if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) { $copyright .= '-' . $copyright_dates[0]->lastdate; } $output = $copyright; } return $output; }
Then open your theme’s footer.php file and add the following code where you want to display the date:
<?php echo smallenvelop_copyright(); ?>
Source: wpmudev
-
With the help of Plugins
If you don’t want to deal with the codes, here is the next solution for you. WordPress repository has many plugins for displaying dynamic copyright date in your website. Here I am listing some of the WordPress plugins that can help you.
Really Great list and I find useful information about how WordPress helps to build the big brands on the internet. Before reading this article I’m not aware of using WordPress CMS for big enterprises. But now I will recommend to my big enterprise clients.
I think ‘Automatic Copyrights Shortcode by linkpakdigital’ should also be placed in this list. I found it very easy and impressive as compare to others in this list. Thanks for sharing!
Good info. Lucky me I ran across your website by chance
(stumbleupon). I’ve saved it for later!
That’s nice, thank you!