Display Post Closest to Today
-
I have a customer who uses the WordPress blog feature to list her upcoming events.
She wants to keep the list of events she has done recently, but would like to display the next event at the top of the page.
So if she has listed events on the 1st, 8th, 15th and 22nd of the month and today is the 9th she would like the event on the 15th to be displayed at the top of the page as well as in the list of posts.
I have found various tutorials about being able to filter the posts that are displayed, but as yet have not found one that allows me to pick a post based on ‘nearest to today’.
If I were writing this is plain SQL it would be something like:-
SELECT * FROM [table] WHERE date =>now() LIMIT 1
What’s the best way to achieve this with WordPress?
Cheers
-
Is this a blog on WordPress.COM? Or a self-hosted WordPress(.org) site?
If it’s the latter, please post it at the WordPress.ORG forums at https://wordpress.org/support/
- The topic ‘Display Post Closest to Today’ is closed to new replies.