Hosting Tutorial & Guide

How to Create a WordPress Copyright With Dynamic Date?

updated on Apr 02, 2015
How to Create a WordPress Copyright With Dynamic Date? At present, a lot of footers on WordPress powered sites include a copyright notice like "© BestHostingSearch, 2015". Obviously, an out-of-the-date copyright date will make your WordPress site look unprofessional and unauthentic. Even more disturbing is you only display the current copyright year without telling your readers how old this site is.

It is not necessary to update the copyright date in the footer of your WordPress site manually every year. And instead, you can set up a dynamic copyright notice on the basis of the date that your posts are published. In the following, we will outline how to achieve this outcome by adding serial PHP codes to the theme's files. In a nutshell, there are two different methods for you to use as below.

Method 1 – Use Simple PHP Shortcode

To be frank, this method is very simple and easy-to-follow even for newcomers who are lack of technical background. To start with, you are expected to log into the dashboard of your WordPress and navigate to "Appearance" > "Editor" as follows. Inside this "Templates" page, you have the ability to have an overall management on your theme's files.

Access Your Template Files via Dashboard

To show your copyright information dynamically in the footer, you may refer to a line of classic PHP code in below. Besides that, this configuration code should be added to the footer.php file located under this "Footer" directory.

copyright © BestHostingSearch, <?php echo date('Y'); ?>

With this date('Y'), the current year for your copyright will be rolled out without any user input, unless you alter your theme again. Keep in mind that the above shortcode requires your WordPress site is no less than one year old. Do not forget to press the bottom "Update File" button to take effect.

Important to Note: Alternatively, you can choose to perform this process via your control panel offered by the hosting provider. Taking the example of the most popular cPanel admin panel here, you should go to "Files" > "File Manager" so as to find out your WordPress installation folder. As you can see, it is required to follow the root of "/wp-content/themes/ThemeFolder/" to select out this footer.php file.

Access Your Template Files via cPanel Control Panel

Method 2 – Use a Third-Party CompicPress Theme

Apart from that, there is another effective way to add such a copyright notice in your WordPress footer according to the set time of your server. Pay attention that, it requires a third-party theme named as ComicPress, and you can still display the current year even if you have run a WordPress site for only one year.

As for detailed steps, you shall go back to the WordPress dashboard and head over to "Appearance" > "Editor" once more. Once done, all you need to do is enter the functions.php file located under this "Theme Functions" directory. To add this dynamic copyright information, you should undoubtedly copy and paste a series of shortcodes as below to this functions.php file.

function bhs_copyright() 
	global $wpdb;
	$published_dates = $wpdb->get_results("
		YEAR(max(post_date_gmt)) AS LastDate
		YEAR(min(post_date_gmt)) AS FirstDate,
		post_status = 'publish'");
	$returnValue = '';
	if($published_dates[0]->FirstDate != $published_dates[0]->LastDate) 
		$copyright .= '-' . $published_dates[0]->LastDate;
			$copyright = "&copy; " . $published_dates[0]->FirstDate;
		$returnValue = $copyright;
	return $returnValue;

After that, you will have to re-open your footer.php file folder within the same "Templates" page. To put an end to this process, you only need to add this shortcode in below to anywhere in this footer.php file. If nothing goes wrong, you will see your copyright footer notice in all its glory now.

<?php echo bhs_copyright(); ?>