Archived topic
Evergreen Copyright
3 replies · Started by sparkle on June 9, 2021
Hi Generatepress Peoples!
Thank you for all you do. I'm trying to replace the automagic single-year copyright dates in the footer (either stock or from the customizer) with an evergreen copyright date like this:
// Copywrite date based on first and last published post
function fonty_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;
}
i tried replacing yours by doing this, but had no luck.
function generate_copyright() {
echo fonty_copyright();
}
How can I do this?
Hi there,
Maybe try adding that function directly in the filter like this?
https://docs.generatepress.com/article/changing-the-copyright-message/#using-a-function
yeah, i was hoping to not interrupt the user's ability to adjust the text in their copyright after %copyright% is used in the customizer.
The filter replaces the entire field unfortunately.