Add Copyright Notices on Your WordPress Site



Adding a copyright notice to your website can also deject people from stealing image. You can simply add a copyright notice to your theme’s footer file in plain text or HTML like this:
1
<p>&copy; 2009-2016 Tutpoints.com</p>
The downside of this is that you will have to edit this code each year. A better approach is to add a dynamic copyright notice in WordPress. Simply add this code to your theme’s functions.php file or a site-specific plugin.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function Tutpoints_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;
}
add_shortcode('copyright','Tutpoints_copyright');
add_filter('widget_text', 'do_shortcode');
This code finds the date of the first post you published on your blog and the last date you published anything. After that it outputs a dynamic copyright notice.
You will need to add the shortcode [copyright] to any post, page or text widget on your site to display copyright notice. You can also use this code in your theme’s footer.
1
<?php echo Tutpoints_copyright(); ?>

Post a Comment

0 Comments