How to target this exact date -x years
-
Hi,
This plugin nearly does everything I need, but I can’t seem to figure out how to target today’s date in previous years. Using the following code, I always get the previous days post from a year ago.[display-posts date_query_before=”-1 years” title=”See what was biting on this day in 2019.” include_excerpt=”true” include_date=”true” include_title=”false” posts_per_page=”1″ ]
I’m posting this on the 16th, but it returns posts from the 15th. This wouldn’t be a problem for a single year as I could use the -days parameter instead, but it starts to get tricky when going back multiple years including leap years.
What I want to accomplish is a way to reach this exact date in previous years reliably. I wasn’t sure if I could use a compound command, but I didn’t think so as I saw nothing in the Codex. I doubt it’s possible, but it never hurts to ask.
In the same vein, I wondered if it was possible to have the title dynamically list the year of the post somehow instead of having it hard coded and having to change it every year.
title=”See what was biting on this day in 2019.”
Thanks for any help or insight.
- The topic ‘How to target this exact date -x years’ is closed to new replies.