Site logo

Archived topic

Aloha - Dynamic Copyright not displaying?

5 replies · Started by William on February 4, 2021

Viewing posts 1–6 of 6

Aloha :)

Hope you are all doing well.

I writing because I'm trying to eliminate the possibility that GeneratePress isn't executing PHP in my custom Footer element.

I created a Code Snippet based on the 21 lines provided here:
https://www.wpbeginner.com/wp-tutorials/how-to-add-a-dynamic-copyright-date-in-wordpress-footer/

I then add a "Custom HTML" block to my Footer element with the following code:

<p>Copyright <?php echo comicpress_copyright(); ?></p>

The word "Copyright" shows up ... but the PHP does not.

Any guesses?

My apologies in advance if this falls outside the realms of GP Support.

You the best! Mahalo :)

Bill

Works! Amazing as always Leo! Thank you :)

It does fail when I try to swap in the function on the website I posted above.

add_shortcode( 'current_year', 'lh_current_year' );

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 = "&copy; " . $copyright_dates[0]->firstdate;
if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
$copyright .= '-' . $copyright_dates[0]->lastdate;
}
$output = $copyright;
}
return $output;
}

}

I would have ZERO ideas on how to correctly write the above :)

Not critical ... I'm just curious if it could be done.

Thank you again!

Bill

I'm not sure what your function does.

But my function simply creates a shortcode that displays the current year.

It displays [Year of First Page or Post - Current Year]

All good here - Thanks for your help Leo.

Have a great weekend :)

No problem :)

This archived topic is closed to new replies.