Adding Dynamic Copyrights

Posted by Edward Caissie on February 16, 2010 in News, WordPress |

We will be adding to all of our themes our latest optimization, the bns_dynamic_copyright() function.

WPFirstAid.com recently wrote a post covering the inclusion of this dynamic copyright function into most any theme. This added functionality will be included with the next update of each of our themes.

Using the get_post() function, bns_dynamic_copyright() essentially finds the blog’s first post; makes note of its date; then creates a copyright notice that takes into account the year in the date of the first (read: oldest) post to recognize the lifetime of the blog.

Here is the code to be placed in the functions.php file:

function bns_dynamic_copyright() {
  /* Get all posts */
  $all_posts = get_posts('post_status=publish&order=ASC');
  /* Get first post */
  $first_post = $all_posts[0];
  /* Get date of first post */
  $first_date = $first_post->post_date_gmt;

  /* Display common footer copyright notice */
  _e('Copyright © ');
  /* Display first post year and current year */
  if ( substr($first_date,0,4) == date(Y) ) {
  /* Only display current year if no posts in previous years */
    echo date(Y);
  } else {
    echo substr($first_date,0,4) . "-" . date(Y);
  }
  /* Display blog name from 'General Settings' page */
  echo ' <strong>' . get_bloginfo('name') . '</strong> ';
  _e('All rights reserved.');
}

… and here is the line of code to replace the old static copyright notice:

<?php bns_dynamic_copyright(); ?>

© 2010, BuyNowShop. All rights reserved.

Related posts:

  1. Shades 1.5.1
  2. Ground Floor 1.4
  3. Multiple Contributors in Desk Mess Mirrored
  4. Featured in DMM v1.7
  5. Shades 1.3.3

Tags: , , ,

1 Comment

Leave a Reply

XHTML: You can use these tags:' <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv Enabled

Copyright © 2009-2010 BuyNowShop All rights reserved.
Multi v1.4.5 a child of the Desk Mess Mirrored v1.7.2 theme from BuyNowShop.com.