Created
February 13, 2018 14:10
-
-
Save CapWebSolutions/5c2236eb8c90fe76a0b6e7bf48424098 to your computer and use it in GitHub Desktop.
Set date of first post as start of copyright time frame in footer.
This file contains hidden or 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
| /** | |
| * This is a function to automatically plug the date of first post into footer. | |
| * | |
| * @package CWS Core Functionality | |
| * @since 1.0.0 | |
| * @author Cap Web Solutions | |
| * @license GPL-2.0+ | |
| * | |
| * @return void | |
| */ | |
| function cws_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