Quantcast
Channel: Sam Glover » PHP
Viewing all articles
Browse latest Browse all 3

Update Your Copyright Notice Automatically

$
0
0

It is easy to forget to update the copyright notice on your website or blog every year. Fortunately, you don’t have to. Instead, you can use this bit of code:

&copy; <?php echo date('Y') ?>

Here is what this will look like on your website:

© 2013

(The code will output the current year, not 2013, if you happen to be looking at this in another year.)

Or, if you prefer, you can modify this to show a range from the beginning of your blog to the current year:

&copy; 2000&ndash;<?php echo date('Y') ?>

Here is how that will look:

© 2000–2013

Add the copyright notice to your theme

If you are building a WordPress theme, you can add the above code directly to your footer.php file, or you can add it to your theme using functions.php. If you go with functions.php, here is the code to use:

function copyright_notice() { ?>
	&copy; <?php echo date("Y")
}

add_action('wp_footer', 'copyright_notice');

If you are using Thesis 1.8.5, use this add_action line, instead:

add_action('thesis_hook_footer', 'copyright_notice');

That’s it — never worry about updating your copyright notice again!


Viewing all articles
Browse latest Browse all 3

Trending Articles