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?

1 Answer 1


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.

  • I completely forgot about the meta_query functionality that was added into the core since 3.1. Nice one! Thank you. Aug 9, 2011 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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