4 ways to Add a Dynamic Copyright Date or Year in WordPress Footer

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.

Dynamic copyright year

4 ways to Add a Dynamic Copyright Date

  1. 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.
    
  2. 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

  3. 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 = "&copy; " . $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

  4. 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.

    1.  Current Year and Copyright Shortcodes
    2. Auto Copyright
    3. Dynamic Dates
    4. Copyright Shortcodes

 

4 thoughts on “4 ways to Add a Dynamic Copyright Date or Year in WordPress Footer”

  1. 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.

    Reply
  2. 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!

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.