Created
January 20, 2016 17:57
-
-
Save anonymous/3fca7441434af22474ef to your computer and use it in GitHub Desktop.
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 | |
// Dynamische Copyright Daten im Footer ausgeben. © Von Jahr bis Jahr... | |
// Im Theme wird die Funktion ausgegeben mit: | |
/* <?php echo ah_dynamic_copyright(); ?> - Diesen Tag dorthin einfügen, wo das Copyright erscheinen soll */ | |
function ah_dynamic_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 = "© " . $copyright_dates[0]->firstdate; | |
if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) { | |
$copyright .= '-' . $copyright_dates[0]->lastdate; | |
} | |
$output = $copyright; | |
} | |
return $output; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment