Dynamic WordPress footer timestamp.

November 2nd, 2016 less than 1 minute read

2017 is almost here. Time to update your site date and copyright settings. Here are a few lines of (WordPress standards compliant) code to add a dynamic timestamp in your footer.php and then forget all about it.

<div class="site-info">
			&copy; <span class="site-name"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span> <?php
			$from_year = 2015;
			$this_year = (int) date( 'Y' );
			echo esc_html( $from_year . (($from_year !== $this_year) ? '-' . $this_year : '') );?>
			<span class="sep"> | </span>
	<?php do_action( 'themeslug_credits' ); ?>
				<a href="<?php echo esc_url( __( 'http://your-link/', 'themeslug' ) ); ?>"><?php printf( esc_html__( 'Theme: %1$s by %2$s.', 'themeslug' ), 'Name', 'Designer Name' ); ?></a>
		</div><!-- .site-info -->

Note that variables like $from_year must be written in snake_case format

The output:

© YourSite 2015-2016 ┃ Theme: Name by Designer Name

chevronLeft icon Previous post

Two kinds of quality

Next post chevronRight icon

Stock status


Leave a comment