I have an Events section as follows:

  1. ⤍ Page 1)
  2. ∟ Subpages 2)
  3. ∟ Sub subpages

1) Own template, w/o sidebars, but query_posts() and get_title/excerpt() from N°2

2) Other subpages are listed in a sidebar left menu - and query_posts() N°3

How can I list N°3 titles/excerpt on N°3 subpages, if they are before and after a date? Where, or how, can I set the Date?

Basically, I need a

  • "coming events" section
  • and a "past events" section

...on every subpage (N°2) with links to N°3 sub subpages of the relevant sub page.

I would then create a sub subpage, give it a date and - on my subpage - (if the date of the sub subpage is in the past) I will list in "past events".

If the date is still later than the current date, I will list it in "coming events".

  • Please try to finish your old Qs when you got answers and comments there. And please write a) in the best english possible and b) the best formatting you can give your Q. Thanks. – kaiser Feb 29 '12 at 14:53

If you're loading additional posts/pages, it's better to use a new WP_Query instance. query_posts is only for modifying the main query.

As for the dates, store them in a custom field in the format yyyy-mm-dd. You'll use php's date to get the current date, refer to WP_Query's custom field parameters for how to query and order based on a field's value.

There are also many similar questions on this site with working code if you search for custom field date.

| improve this answer | |
  • Thanks, sounds pretty simple, I am happy I won't have to do cats and taxonomies and can work it like that with pages/subpages/sub subpages. I will get back here if I am having problems with the query, will try that tomorrow. – Chris Feb 29 '12 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.