Archived topic
Date-based copyright name
6 replies · Started by Anonymous on August 4, 2016
I have spent hours over several days trying to find the answer to the following need:
A blogger's copyright info is included automatically with each post. The blogger got married and changed her last name. How to get WordPress to use old name in copyright line for posts before wedding date and new name in copyright line for posts after the wedding date?
I know get_the_date is key, but I don't know how to write a conditional statement that says if post publication date is before October 1 2009, display maiden name, else display married name.
(Or, of course, if post publication date is after wedding date, display married name.)
Thank you for reading this (and hopefully solving the mystery for me).
PS: Which is better for you: asking here on your site or asking over at https://wordpress.org/support/theme/generatepress?
That's an interesting question - how are you currently adding the copyright? In a hook? Template file?
Thank you, Tom.
Right now it's in a child theme footer.php like so:
© Copyright <?php echo the_date('Y'); ?> AuthorName
Create a new user for use after the wedding date?
No idea if this will work, but worth a try:
<?php
global $post;
$compare_date = strtotime( "2009-10-01" );
$post_date = strtotime( $post->post_date );
if ( $compare_date >= $post_date ) {
?>
On or before Oct 1.
<?php
} else {
?>
After Oct 1.
<?php
}
?>
WooHoo! It works!
Thank you very much, Tom! I am extremely grateful.
Of all things, this was the part that had me stumped: ( "2009-10-01" ). Such a simple thing...
You're very welcome :)