• Hi,

    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter nathanadams

    (@nathanadams)

    Hi Esmi,

    What I’m looking for isn’t multiple loops, but to do it within the one loop (so that example order I had in the original question would be the order they appear within the one loop).

    I already have modified the loop via query_posts to include both posts and the custom post type
    <?php query_posts( array( 'post_type' => array( 'post', 'twentyyearsago' ) ) ); ?>
    It’s just a matter of ratcheting the date of the twentyyearsago posts up 20 years.

    Cheers

    Thread Starter nathanadams

    (@nathanadams)

    I’ve read through the WP_Query page, and specifically the Time Parameters section, and I still can’t see anything there to achieve what I want to do.

    I can see the posts_where filter examples, but I’m not looking to set the date range of the query. More to add 20 years to the date of the posts with the post_type twentyyearsago, and then process the query with both the posts and twentyyearsago posts together.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add 20yrs to post date, and then query’ is closed to new replies.