I would like to know if anyone knows a way of adding a timeframe (say 20 years) to the datestamp on a set of posts, and then running a query on the loop which uses the new date?
Basically what I want to do is have a series of normal news posts. In addition to that, I have a custom post type for ’20 years ago today’, with the posts in that date stamped appropriately in the early 90s. I’d like for those posts to appear in the same loop as the news posts (rather than in a separate loop).
So it might go:
- News Post (21 March 2012)
- News Post (19 March 2012)
- 20 years ago (17 March 1992)
- News Post (12 March 2012)
- 20 years ago (6 March 1992)
and so on. And anything that happened less than 20 years ago (say, in 1993), would behave like a pending post, and not show up.
Any suggestions would be appreciated
An example, that uses the
posts_where
filter. If you need to extend a query using theposts_clauses
filter, then just exchange$where
with$pieces
and set$pieces['where'] .=
instead of$where .=
. Just drop that into your functions.php file and add some conditional tag before querying the posts.Edit: So, here’s the original loop from the OP: