Last active
December 17, 2015 11:59
-
-
Save glueckpress/5606991 to your computer and use it in GitHub Desktop.
[WordPress] Dynamic copyright date depending on when the first post was published.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Dynamic copyright date. | |
* | |
* Dynamic copyright date depending on | |
* when the first post was published on your site. | |
* | |
* Derived from: http://alex.leonard.ie/2010/07/27/wordpress-tip-get-the-date-of-your-first-post/ | |
* | |
*/ | |
function gp1305_dynamic_copyright_date() { | |
$args = array( | |
'numberposts' => -1, | |
'post_status' => 'publish', | |
'order' => 'ASC' | |
); | |
$posts = get_posts( $args ); | |
$first = $posts[0]; | |
$date = date( 'Y', strtotime( $first->post_date ) ); | |
return ( intval( $date ) < date( 'Y' ) ) ? intval( $date ) . '-' . date( 'Y' ) : date( 'Y' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment