Question

I've got an "event" custom post type, with a meta field is used for the event date. I've successfully created archive pages (year and month) based on the answer on a previous question (here). Now, I'm trying to create a listing of the archives, sort of like wp_get_archives would work. Example:

2012

  • January
  • February
  • March
  • etc

2011

  • January
  • February
  • March
  • etc

The query I'm running to gather up all the dates from the meta_key is this:

$query = $wpdb->get_col( "SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = 'event_date' ORDER BY meta_value DESC" );

But I'm not sure how I can take that data and list it out like the above example. I know I can output the unique dates as is with a foreach loop. That, my output is as follows:

2012-07-15 2011-06-07 2011-01-10

Trying to get it all sorted in the list format, I'm completely unsure of. Any help with this one is greatly appreciated!

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top