Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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.

http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters

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);
ksort($meta_date_array);

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. –  DigitalSea Aug 9 '11 at 22:14
add comment

Your Answer

 
discard

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.