Publish only recent posts using get_post()
-
I want to show the latest 2 posts on my home page but ONLY if they were published in the last month (at the moment I have the last 3, but as I have been otherwise occupied and haven’t published, they are very old and it looks ridiculous).
It’s outside the loop so it would have to use get_post(). I can find how to create a conditional filter using dates for query_post() but not for get_post()and not being a programmer I can’t work out how to apply it.
It seems I need some sort of function because I want first to create an array of the last 2 posts, check their date of publication and if one or both satisfy the condition of being younger than 30 days, do something (put a heading in the div) and, if not, do nothing. Then for the articles that satisfy the date criteria, output the title, excerpt and date.
I think I can see the mechanics of it – it’s the detail that completely flummoxes me !
- The topic ‘Publish only recent posts using get_post()’ is closed to new replies.