WordPress: Here’s a unique, copyright-free PHP code snippet you can use to create a dynamic copyright footer in WordPress:
<?php
/**
* Dynamic Copyright Footer for WordPress
* This code is free to use and modify
*/
function dynamic_copyright_footer() {
$site_name = get_bloginfo('name');
$start_year = 2020; // Change this to your site's first year
$current_year = date('Y');
// Determine year display
$year_display = ($start_year == $current_year) ? $current_year : $start_year . ' - ' . $current_year;
// Build the copyright notice
$copyright = sprintf(
'© %s %s. %s',
$year_display,
esc_html($site_name),
__('All rights reserved.', 'text-domain')
);
// Optional: Add a custom message
$custom_message = __('Content licensed under Creative Commons.', 'text-domain');
// Output the footer
echo '<div class="copyright-footer">';
echo '<p>' . $copyright . '</p>';
echo '<p>' . $custom_message . '</p>';
echo '</div>';
}
How to Use This Code:
- Add this code to your theme’s
functions.php
file or a custom plugin - Call the function in your footer template with
<?php dynamic_copyright_footer(); ?>
Customization Options:
- Change
$start_year
to match when your website was first published - Modify the copyright text as needed
- Update the
text-domain
to match your theme’s text domain - Add CSS styling to the
.copyright-footer
class
This code is completely free to use and modify without any copyright restrictions. It automatically updates the year and can be easily customized to fit your site’s needs.