New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gettting the year/date for a post not working in my WP install #1

tonzyl opened this Issue Jan 18, 2019 · 1 comment


None yet
2 participants
Copy link

tonzyl commented Jan 18, 2019

Not sure why but the line
$post_year = date("Y", strtotime( get_the_date() ));
in your code
gives me the current year, breaking the entire if then loop that creates the strong header per year.

When I changed it to $post_year = get_the_date('Y');
it worked as your examples suggest.

I'm on WP 5.0.3.


This comment has been minimized.

Copy link

cogdog commented Jan 18, 2019

Hmmm, and I have no idea why I wrote what looks redundant, probably lifted from another example.

Made an adjustment in the plugin, thanks. It should not be needed, but just to be sure, I am passing the ID of the post too

$post_year = get_the_date('Y', $posts_from_today->post->ID );

@tonzyl tonzyl closed this Feb 1, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment