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 a post with a custom meta value which is populated via a jQuery datepicker and it gets stored in the following format: yyyy/mm/dd - is there a way I can group all posts from the same day together easily?

I'm not using Wordpress's publish date, as I need to have future posts published. I know using the function 'the_date()' will by default in Wordpress only show the date once per x amount of posts, giving the appearance they're grouped. Is there anything that does something similar with a custom meta date value?

share|improve this question
up vote 1 down vote accepted

The only built in way ( using a function) is to use WP Query and the custom field parameters, specifically meta_query and compare.


An example to get you started:

$query = new WP_Query( array( 'meta_key' => 'your_date',  'meta_compare' => '=' ) );

Alternatively, the custom field functions in Wordpress do not have many parameters, they are basically for adding and retrieving data, which you can then use with native PHP, for instance you can return the custom field as an array using something like:

$meta_date_array = get_post_meta($post_id, $key, false);

and use PHP's ksortto sort the order.

share|improve this answer
I completely forgot about the meta_query functionality that was added into the core since 3.1. Nice one! Thank you. – Dwayne Charrington Aug 9 '11 at 22:14

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.