WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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".

share|improve this question
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
up vote 0 down vote accepted

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.

share|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. – C D Feb 29 '12 at 16:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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