php wp copyright and year

Solutions on MaxInterview for php wp copyright and year by the best coders in the world

showing results for - "php wp copyright and year"
Paola
03 Jan 2020
1function comicpress_copyright() // returns:  (c) My blog Name 2014 - 2021
2{
3    global $wpdb;
4    $copyright_dates = $wpdb->get_results("
5    SELECT
6    YEAR(min(post_date_gmt)) AS firstdate,
7    YEAR(max(post_date_gmt)) AS lastdate
8    FROM
9    $wpdb->posts
10    WHERE
11    post_status = 'publish'
12    ");
13    $output = '';
14    if ($copyright_dates) {
15        $copyright = "© " . get_bloginfo('name') . ' ' . $copyright_dates[0]->firstdate;
16        if ($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
17            $copyright .= '-' . $copyright_dates[0]->lastdate;
18        }
19        $output = $copyright;
20    }
21    return $output;
22}