How to add copyright in footer of wordpress without plugins?


I am using the twentytwelve theme. It is one of default WordPress Theme. It has footer branding ‘Powered by WordPress’. I am here talking about self-hosted WordPress theme.
Here, I shall talk about how to add copyright in the footer of WordPress without plugins:

  • Here I shall not use the available plugin to add the copyright notice. Here, I shall modify theme of WordPress.
  • Learn to Create Child Theme from an unmodified Parent Theme.
  • Modification with Child Theme is safe. Here I shall write the code of copyright in the footer which will dynamically change with year automatically

How to create a dynamic copyright notice?

  • Log in to cPanel. Put USERNAME and PASSWORD.
  • Go to FILES/FILE MANAGER/WP-CONTENT/THEMES/twentytwelve-child/FUNCTIONS.PHP
  • Here I am modifying twentytwelve-child theme so I choose it.
  • Select FUNCTIONS.PHP from left-hand top left choose EDIT.
  • Here I am using twentytwelve-child theme.
function create_copyright() {
$all_posts = get_posts( 'post_status=publish&order=ASC' );
$first_post = $all_posts[0];
$first_date = $first_post->post_date_gmt;
_e( 'Copyright © ' );
if ( substr( $first_date, 0, 4 ) == date( 'Y' ) ) {
echo date( 'Y' );
} else {
echo substr( $first_date, 0, 4 ) . "-" . date( 'Y' );
}
echo ' <strong>' . get_bloginfo( 'name' ) . '</strong> ';
_e( 'All rights reserved.' );
}
  • Paste the following code at the end of FUNCTIONS.PHP file. (Refer Screenshot)

 

  • Click SAVE CHANGES from the right-hand top.
  • Then open the FOOTER.PHP file of your child theme by going to FILES/FILE MANAGER/WP-CONTENT/THEMES/twentytwelve-child/FOOTER.PHP
  • Select FOOTER.PHP and then click on EDIT.
  • Search for
<a href="<?php echo esc_url( __( 'https://wordpress.org/', 'twentytwelve' ) ); ?>" class="imprint" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'twentytwelve' ); ?>">
<?php printf( __( 'Proudly powered by %s', 'twentytwelve' ), 'WordPress' ); ?>

 

  • Just before it paste the following code.
<?php create_copyright(); ?>
  • Then SAVE CHANGES. (refer Screenshot below)

Now look at your Blog’s footer and you will see something like this.

Copyright © -2018 MEKAP All rights reserved

It is a dynamic copy text and the year will change to the latest years in accordance with the change of time.


Related Posts:


 

Author: AMCANDROMEDAGALAXY

Blogger by choice.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.