Black Friday Sale! Get up to $30 off GP Premium! Learn more ➝

[Resolved] Date-based copyright name

Home Forums Support [Resolved] Date-based copyright name

Home Forums Support Date-based copyright name

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #215528
    Mark Roth

    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?

    #215599
    Tom
    Lead Developer
    Lead Developer

    That’s an interesting question – how are you currently adding the copyright? In a hook? Template file?

    #215742
    Mark Roth

    Thank you, Tom.

    Right now it’s in a child theme footer.php like so:

    © Copyright <?php echo the_date(‘Y’); ?> AuthorName

    #215748
    David

    Create a new user for use after the wedding date?

    #215750
    Tom
    Lead Developer
    Lead Developer

    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
    }
    ?>
    #215788
    Mark Roth

    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…

    #215809
    Tom
    Lead Developer
    Lead Developer
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.