A tip for self-hosted WordPress users.
Contrary to popular belief, most blogs are copyrighted. As a result, most blog themes include a copyright notice in the footer.
How the copyright notice is entered into the theme determines how it appears:
- If entered as plain text, it appears as a static date or range of dates — whatever you entered. This means that each new year — right about now — you need to change the static text to include the current year.
- If entered using tags that pull the most recent date’s year from your WordPress blog — or just use the current year — a range of dates may not appear at all. Instead, there will be just one date. That’s better, but not exactly accurate.
- If entered using PHP tags that get the first and last years of blog posts and put them in a range — you never have to modify the footer to change the dates and they always include the entire range of post years. This is the best solution and it isn’t difficult to do.
To automatically display a range of dates from the year of your first post to your most recent post in a copyright notice, just edit the code in the footer to remove your current copyright notice code and replace it with this:
<?php
global $wpdb;
$post_datetimes = $wpdb->get_results("SELECT YEAR(post_date_gmt) AS year FROM $wpdb->posts WHERE post_date_gmt > 1970 ORDER BY post_date_gmt ASC");
$firstpost_year = $post_datetimes[0]->year;
$lastpost_year = $post_datetimes[count($post_datetimes)-1]->year;
$copyright = __('Copyright © ') . $firstpost_year;
if($firstpost_year != $lastpost_year) {
$copyright .= '-'. $lastpost_year;
}
echo $copyright;
?>
<?php bloginfo('name'); ?>
The result, on this blog, would be something like:
Copyright © 2004-2009 Maria's Guides
If you prefer to have your name appear instead of the name of your blog, replace the last line with your name. That’s what I do.
Learn More
Learn more about working with a self-hosted WordPress 2.7 installation — or WordPress.com. Check out my WordPress courses on Lynda.com.













1 response so far ↓
1 Lorelle // Jan 7, 2009 at 5:45 pm
Excellent. I’ve been using dynamic copyrights for YEARS with JavaScript, but updating this way is much better. Thanks!
And contrary to what most think, EVERYTHING published on the web is copyrighted by the original creator (or owner of the copyright) of the content. What the owner choose to allow to be done with the content is up to them. They can give it away, allow selective use, or allow no use of the content, beyond Fair Use and whatever their home country copyright laws permit.
Whatever they choose, they have to tell the world what their choice is regarding the use of their content. A link to their copyright policy in their copyright notice should be required, taking the visitor to a page that describes what their copyright policy is. Might want to offer an example with a link wrapped around the code to help them do that.
We need to keep educating people about copyright so they know that they own what they create, therefore, they have the power to decide what they do with it.
Thanks again for the code!
Lorelle´s last blog post: Cooking Up a Story: NPR Explores Web Businesses
Leave a Comment