Skip to content

Instantly share code, notes, and snippets.

@jatinhota
Last active February 2, 2017 21:14
Show Gist options
  • Save jatinhota/f50cdf3b0724fc7a9e867a9f1a984a5a to your computer and use it in GitHub Desktop.
Save jatinhota/f50cdf3b0724fc7a9e867a9f1a984a5a to your computer and use it in GitHub Desktop.
Comicpress dynamic Copyright Date
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 = "© " . $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