WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
    • How to Start a Blog
    • Create a Website
    • Start an Online Store
    • Best Website Builder
    • Email Marketing
    • WordPress Hosting
    • Business Name Ideas
  • Deals
    • Bluehost Coupon
    • SiteGround Coupon
    • WP Engine Coupon
    • HostGator Coupon
    • Domain.com Coupon
    • Constant Contact
    • View All Deals »
  • Glossary
  • Videos
  • Products
X
☰
Beginner's Guide for WordPress / Start your WordPress Blog in minutes
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

WPBeginner» Blog» Tutorials» How to Add a Dynamic Copyright Date in WordPress Footer

How to Add a Dynamic Copyright Date in WordPress Footer

Last updated on January 8th, 2021 by Editorial Staff
138 Shares
Share
Tweet
Share
Pin
Free WordPress Video Tutorials on YouTube by WPBeginner
How to Add a Dynamic Copyright Date in WordPress Footer

Often you will see a website that has an outdated copyright date which is pretty annoying. There are also sites that only show the current year for their copyright date which is even more annoying because you won’t know how old the site is. There is a simple PHP solution to this that most developers would know, but there is a more elegant way that we will show you. In this article, we will share a function that will automatically generate a copyright date based on the published date of your oldest and newest post.

Simple PHP Solution for Dynamic Copyright Date

For this method, you’ll need to add some code to your WordPress theme files. If you haven’t done this before then checkout our guide on how to copy and paste code in WordPress.

The most common way to display a dynamic copyright date is by editing your WordPress theme’s footer.php file. Simply copy and paste the following code at the line where you want to display the copyright notice.

<p>&copy; 2020 – <?php echo date('Y'); ?> YourSite.com</p>

The problem with this code is that it cannot dynamically fetch your site’s start date and your site has to be at least an year-old before you can use it.

Elegant WordPress Solution for Dynamic Copyright Date

While surfing the web, we saw a more elegant solution suggested by @frumph of CompicPress Theme.

This code will generate a dynamic copyright date based on the published date of your oldest post and your newest post. If it is the first year of your site, then this function will only display the current year.

To add this, first you need to add the following code to your theme’s functions.php file or a site-specific plugin.

function comicpress_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 = "&copy; " . $copyright_dates[0]->firstdate;
if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
$copyright .= '-' . $copyright_dates[0]->lastdate;
}
$output = $copyright;
}
return $output;
}

After that, you need to add the following code to your theme’s footer.php file where you want to display the date:

<?php echo comicpress_copyright(); ?>

This function will add the following text:

© 2009 – 2021

Don’t keep your copyright dates outdated. Take advantage of this technique in your current and future WordPress sites.

138 Shares
Share
Tweet
Share
Pin
Popular on WPBeginner Right Now!
  • How to Fix the Error Establishing a Database Connection in WordPress

    How to Fix the Error Establishing a Database Connection in WordPress

  • Revealed: Why Building an Email List is so Important Today (6 Reasons)

    Revealed: Why Building an Email List is so Important Today (6 Reasons)

  • Checklist

    Checklist: 15 Things You MUST DO Before Changing WordPress Themes

  • How to Properly Move Your Blog from WordPress.com to WordPress.org

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Trusted by over 1.3 million readers worldwide.

The Ultimate WordPress Toolkit

45 Comments

Leave a Reply
  1. Taariqq says:
    Dec 29, 2019 at 3:06 am

    Most helpful! Brings a level of credibility to my site.
    Thank you!

    Reply
    • WPBeginner Support says:
      Dec 30, 2019 at 11:38 am

      You’re welcome :)

      Reply
  2. Zee Aitch says:
    Jan 25, 2019 at 7:42 am

    I think we should not waste time reinventing the wheel our self, instead utilizing the available plugins like Automatic Copyrights Shortcode.

    What you think?

    Reply
    • WPBeginner Support says:
      Jan 25, 2019 at 11:04 am

      That plugin was not available when this post was created, we will certainly take a look at it

      Reply
  3. Def Egge says:
    Jun 20, 2018 at 12:23 pm

    I gave this a try and, for a moment, it appeared to work.

    Clearing the WP cache and reloading the page resulted in the same old “Blah … blah … blah … | Proudly powered by WordPress” footer.

    I no longer see this code snippet in the functions.php file for the ComicPress theme.

    Does it matter WHERE in the functions.php and footer.php files the code snippets are added? If so, it would be a great help to know that.

    Thanks!

    Reply
  4. Kori says:
    May 23, 2018 at 1:33 pm

    Does it have to be a child theme for this to stay in place? I’m on Twenty Seventeen, with no child theme. Do I need to worry about this being overwritten every time I get a WP udpate?

    Appreciate the help so much!

    Reply
  5. karakaplan says:
    Sep 17, 2017 at 12:07 am

    I just want to put current year. How to do that?

    Reply
    • Nick says:
      Feb 4, 2018 at 6:48 pm

      You can put the current year by just calling the php date() function with a ‘Y’.

      echo date(‘Y’);

      Reply
  6. Anna says:
    May 18, 2017 at 5:40 am

    Could someone assist with information on how to add a text after the year? Where in the code should this be placed?

    Reply
    • Calvin Joseph Terlizzi says:
      Oct 7, 2017 at 4:09 pm

      Hah! Worked on the first try. Thanks guys!

      Reply
  7. Rishabh says:
    Mar 6, 2017 at 1:25 pm

    After i clicked save on the functions.php. I’m facing a white-screen of death. I also dowloaded the functions.php file but couldn’t find your code there. How do i solve it?

    Reply
    • WPBeginner Support says:
      Mar 6, 2017 at 4:41 pm

      Hey Rishabh,

      You probably downloaded incorrect functions.php file. Remember, all themes installed on your website have functions.php file. You’ll need to edit the file in your current WordPress theme folder.

      Reply
      • Sarah Andert says:
        May 10, 2017 at 10:09 pm

        I am also having this problem and have no idea what you mean by “edit the file in your current WordPress theme folder”

        I went into Appearance then Editor and just clicked on the right hand side where I saw “Functions.php” and pasted in the code you listed. Now none of the options under appearance will even open, including Editor, Custom CSS and Edit CSS. I have no idea what to do, please help!

        Reply
        • WPBeginner Support says:
          May 10, 2017 at 10:20 pm

          Hi Sarah,

          You can undo the changes you made to the functions file using an FTP client.

        • Sarah Andert says:
          May 10, 2017 at 10:30 pm

          Actually I think I figured it out! You mean editing the theme this way, right?
          https://www.wpbeginner.com/wp-tutorials/how-to-manually-update-wordpress-using-ftp/

        • WPBeginner Support says:
          May 11, 2017 at 11:49 pm

          Yes, this way you will be able to quickly undo changes if they break your site.

  8. Nikhil says:
    Nov 22, 2016 at 12:48 pm

    I need to change ” Last updated on January 5th, 2016 by Editorial Staff ” this date with current date…

    So which command I have to use…. I had tried this one…

    But I’m getting the same date…

    Reply
    • WPBeginner Support says:
      Nov 22, 2016 at 1:13 pm

      Please see our tutorial on how to display last updated date of your posts in WordPress

      Reply
  9. Amanda says:
    Nov 16, 2016 at 1:34 pm

    Is there a way to do this using Jetpacks CSS editor?

    Reply
  10. gumusdis says:
    Oct 21, 2016 at 8:15 am

    Thanks! this is great, i used it on my website
    I added a post for 1 year ago, like 2015 to have more than 1 year. then I realized I could simply write down 2015 in code lol..
    anyway i hope you laughed..

    Reply
  11. Kyle says:
    Sep 28, 2016 at 8:28 am

    This is WordPress Beginner!!! Why Don’t You tell the guys where exactly to put the code on PHP file? See lots of people breaking their websites so I would rather not try.

    Reply
  12. lena woods says:
    Sep 12, 2016 at 4:38 pm

    I added the code to functions, and it completely wiped out my website. Blank screen – when i go to login page and when i simply type in my website URL. what happened? did exactly what was said tot do above :/

    Reply
    • WPBeginner Support says:
      Sep 14, 2016 at 7:49 pm

      Please see our guide on troubleshooting WordPress issues.

      Reply
  13. Hamza Ahmed says:
    Aug 27, 2016 at 1:23 pm

    Is there a way to have dynamic years in WordPress titles too?

    Reply
  14. Christina says:
    Aug 18, 2016 at 10:46 am

    Great share,
    thanks a lot. I have searched so long how to remove the copyright in wordpress.

    Greets Christina

    Reply
  15. Mark Roth says:
    Aug 3, 2016 at 12:34 am

    I have spent hours over several days trying to find the answer to the following need:

    A blogger’s copyright info is included automatically with each post. The blogger got married and changed her last name. How to get WordPress to use old name in copyright line for posts before wedding date and new name in copyright line for posts after the wedding date?

    I know get_the_date is key, but I don’t know how to write a conditional statement that says if post publication date is before October 1 2009, display maiden name, else display married name.

    (Or, of course, if post publication date is after wedding date, display married name.)

    I’m hoping one of you here will help me with this. Please?

    Reply
  16. Michaela says:
    Jan 26, 2016 at 8:50 am

    Hi, I tried to update the functions.php file, but instead I received 500 Error. What shall I do? It does not allow me to access my wordpress account to edit it back…. can you please help me?

    Reply
    • WPBeginner Support says:
      Jan 26, 2016 at 5:42 pm

      You can remove the code by editing your functions.php file using an FTP client.

      Reply
  17. Mirco says:
    Aug 15, 2015 at 5:27 am

    You can also try the Copyright Shortcodes plugin (it’s on the WordPress plugin directory).

    Available shortcodes are: [copyright year=YYYY], [copy], [year], [years by=YYYY list=true/false sep=“, “]

    Cheers,

    Reply
  18. Brandon Hann says:
    Feb 5, 2015 at 1:44 pm

    This is the code I used for a long time until I realized that the year is pulled based off of GMT, so if you don’t want users in different time zones to see your site’s year change early or late, don’t use this tag…change echo date to echo date_i18n

    For example, when I used the original code, I went to my website on Dec 31st, 2014 at around 6pm PST. My website was already showing the year 2015 because Pacific Standard Time is 8 hours behind GMT.

    With the date_i18n change, your site will show the current year based on the visitor’s timezone instead. For those that are curious, i18n is an abbreviation of “internationalization” because there are 18 letters between the ‘I’ and the ‘N’.

    Reply
    • shahrukh says:
      Apr 10, 2018 at 11:53 pm

      Can you show me how you add i18n in above code

      Reply
  19. hayward says:
    Feb 10, 2014 at 1:11 am

    I am having trouble with adding the code to my function.php footer. Now I am getting this error message Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /home3/hsp1990/public_html/wp-content/themes/couponpress/functions.php on line 35

    Reply
    • Rex AZ says:
      Dec 15, 2014 at 12:49 pm

      You should use a child theme rather than working with your parent theme. Just go over to the wordpress codex and source for child theme development. Just create a new functions.php file and a footer.php file in your child theme directory and insert the codes. You are good to go.

      Reply
  20. Chris says:
    Jan 9, 2014 at 12:23 pm

    Hi,
    how can I modify this code, so that I can have a fix “first date” of “1999”, instead of the date of the first published posting?
    Thanks.

    Reply
    • Emilio G. says:
      Jan 10, 2014 at 8:15 pm

      type in 1999 before the code.

      Reply
  21. menj says:
    Feb 13, 2013 at 10:19 am

    I have used the code above, with a slight modification to the comicpress_copyright() function which I renamed to a more generic one.

    Reply
  22. jrstaples1 says:
    Aug 3, 2011 at 7:01 pm

    Nice tip! I addded this with almost zero coding knowledge. How would I add my site title after the year?

    Reply
  23. Ole says:
    Apr 17, 2011 at 11:35 am

    Wow. This is great. Thank you

    Reply
  24. Dominic says:
    Jul 19, 2010 at 8:02 pm

    Something like this might be easier and less intensive.

    <?php
    $year = date('Y');
    if ($year != 2009){
    echo '© 2009 – '.$year.' YourSite.com';
    } else {
    echo '© 2009 YourSite.com';
    }
    ?>

    Reply
  25. Gary says:
    Jun 8, 2010 at 10:16 am

    It’s worth pointing out that copyright exists for a number of years from the first time it was published. That means there’s to things to consider:

    1) The visual copyright notice is not necessary under the Berne treaty – it has no standing in law whether you have it on the site or not.

    2) If the site was first published in a certain year, claiming it could be actually published in a later year actually lowers any claim you may have for copyright infringement.

    Also, most visual copyright notices, for what they are worth, also need to put who the copyright is to, after the year(s).
    Finally, it’s typographically correct to use an “en dash” instead of the hyphen-minus character you’ve suggested.

    Reply
    • Dave Hildebrand says:
      Sep 23, 2010 at 10:43 pm

      Surprised this hasn’t been added to every theme writers toolbox.

      I changed – to – and added in my name as per Gary’s comments.

      Reply
  26. Maverick says:
    May 25, 2010 at 9:34 am

    Little better way for this feature is to add php variable about site name (able to change in admin panel), for example:
    © 2009 –

    Reply
  27. anggiaj says:
    May 16, 2010 at 8:49 am

    Great tips, problem solved, thanx

    Reply
  28. Zhu says:
    May 14, 2010 at 8:28 pm

    Thanks for the tip! I implemented that in about 60 seconds :-)

    Reply
  29. Derek Jensen says:
    May 14, 2010 at 7:28 am

    It surely does bug me when I go to a site and the copyright is out of date but yet they are publishing fresh content.

    This will be a nice dummy factor for that.

    As always I enjoy your guys as a WordPress resource.

    Reply

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Over 1,320,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
All in One SEO logo
All in One SEO
Improve website SEO rankings with AIOSEO plugin. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 30 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2020 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2020)
    • How to Choose the Best Domain Registrar (Compared)
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • How to Register a Domain Name (+ tip to get it for FREE)
    • HostGator Review - An Honest Look at Speed & Uptime (2020)
    • SiteGround Reviews from 4196 Users & Our Experts (2020)
    • Bluehost Review from Real Users + Performance Stats (2020)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Create an Email Newsletter the RIGHT WAY (Step by Step)
    • Free Business Name Generator (A.I Powered)
    • How to Create a Free Business Email Address in 5 Minutes (Step by Step)
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2020 – Step by Step Guide
Deals & Coupons (view all)
SeedProd Logo
SeedProd Coupon
Get 50% OFF SeedProd Coming Soon Page plugin for WordPress.
Cozmoslabs
Cozmoslabs Coupon
Get 15% OFF on Cozmoslabs WordPress premium plugins.
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).
Join our team: We are Hiring!

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
  • Free Business Tools
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • SeedProd
  • Nameboy
  • RafflePress
  • Smash Balloon

Copyright © 2009 - 2021 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

Managed by Awesome Motive | WordPress hosting by SiteGround | WordPress CDN by MaxCDN | WordPress Security by Sucuri.