I have three custom fields set for each of the posts in the events category — year, month, and day. I am already querying for the events category, and now I'd like to sort the posts by the custom fields. I assume that I just need to insert something into the query_posts section of the code, but I'm not sure what. Any suggestions?
<?php query_posts('category_name=events&showposts=6'); ?> <?php while (have_posts()) : the_post(); ?> <li> <div class="date"> <span class="day"><?php echo get_post_meta($post->ID, 'month', true); ?>/<?php echo get_post_meta($post->ID, 'day', true); ?></span> <span class="year"><?php echo get_post_meta($post->ID, 'year', true); ?></span> </div> <div class="details"> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> →</h3> </div> </li> <?php endwhile; ?>
I can explain more: the date the post was created is unimportant, but I want to sort first by the "year" custom field, then by the "month" custom field, and then by the "day" custom field