Show posts based on event date (custom variable)
-
I am developing my first custom theme, my client is a theatre company/venue.
On the home page, what I would like to do is show a “rolling” list of the next upcoming three shows. Each upcoming show is displayed using a post with an excerpt and a featured image. Many shows are posted well in advance of the performance dates so there may be 5-10 shows that are posted under the “current season” section of the site. This is ideal.
However, in order to display the three upcoming events on the homepage automatically I would need to somehow tell WordPress to display a maximum of three posts based on the date of the performance and NOT based on the date that the post was published.
I’m thinking it would be something along the lines of assigning a custom field that I insert a date range into for each post and then build some php code that checks to see:
1) If the date range has passed
2) If not, how far away is the start of the date range from the current day (new variable)
3) Finally, sort a max of three posts based on that newly created variable in ascending order.I understand exactly that code I need, but am not experienced enough to build it myself.
Anyone out there have either some code to use or a different way I might be able to do that?
Thanks!
(ps: I do not have a link to include because I am building this theme in a local environment on my computer and I’m simply looking for functionality advice.)
- The topic ‘Show posts based on event date (custom variable)’ is closed to new replies.