Site logo

Archived topic

Evergreen Copyright

3 replies · Started by sparkle on June 9, 2021

Viewing posts 1–4 of 4

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?

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.

This archived topic is closed to new replies.