1

This may be pretty specific & a bit of a newb question but PHP is one of my weaker areas - I think I know what's causing the problem, I'm just not sure what to replace it with. The issue looks like get_the_date() shows the date that the post (page, etc) was created, rather than the current date. I've been poring over the documentation on the_date (https://developer.wordpress.org/reference/functions/the_date/) but I haven't figured out what I should replace get_the_date( 'Y' ) with & I think it's partially because of the shorthand that we've used on our function, which took me a couple hours to put together, I'm afraid.

Here's what we're currently using:

// Custom Footer Credits
add_filter('genesis_footer_creds_text', 'custom_footer_creds_filter');
function custom_footer_creds_filter( $editthecredit ) {
  $editthecredit = 'Copyright © ';
  $editthecredit .= get_the_date( 'Y' );
  $editthecredit .= ' ';
  $editthecredit .= get_bloginfo( 'name' );
  return $editthecredit ;
}
// End Footer Credits

The issue is that get_the_date( 'Y' ) returns the date that the page was created. I've seen where folks have used echo get_the_date( 'Y' ) but that breaks the site.

I thought at first it was because we may need to deregister the default Genesis footer so I used some of Brian Gardner's advice here (https://studiopress.blog/customize-genesis-site-footer/) but it made no difference.

Jeff W
  • 147
  • 1
  • 2
  • 13
  • 1
    so you want to echo current year, `date('Y')` ?...http://php.net/manual/en/function.date.php – MakeLoveNotWar Oct 30 '18 at 19:43
  • Correct - using the code as shown, though, it's only showing the creation date of the page currently being viewed. Also, adding "echo" into the mix brings on the WSOD – Jeff W Oct 30 '18 at 19:44

1 Answers1

3

WordPress' the_date functions are intended to show the date of the current Loop item (Post, Page, etc).

If you want today's date, use PHP's default date function. For example, the following prints out today's year:

echo date('Y');

specifically for your case:

$editthecredit .= date('Y');
DACrosby
  • 11,116
  • 3
  • 39
  • 51
  • That's it! Bloody simple & does exactly what we needed - thanks DACrosby! I'll mark this as the accepted answer. – Jeff W Oct 30 '18 at 19:48