Wordpress Posts Foreach sorting and Grouping

HI,

I have a wordpress page which im setting up to show the dates and locations of concerst my band has booked. In wordpress there are only two fields, title and post. i need to use three. to get round this i have made the title have the date and venue seperated by a delimiter in this case the vertical line |. i then use the explode function to split the two variables out for the display. so far the code I have is working fine, here it is

[php]<?php
$posts = get_posts(‘category_name=Engagement’);

if (empty($posts)) {
echo “

We have no Engagments booked…
” ;
} else {

foreach ($posts as $post) : setup_postdata( $post );

$ingress = get_the_title();
$postex = explode("|", $ingress );
$date = “$postex[0]”;
$venue = “$postex[1]”;
$desc = get_the_excerpt();
$unixdate = strtotime($date);
$eng_mth = date(‘F’, $unixdate);
$eng_date = date(‘d/m/y’, $unixdate);

echo "

$eng_mth

$eng_date
$venue
$desc
" ?> <?php endforeach; } ?>[/php]

This is displaying the engagement posts ok but I would like to alter how they are displayed. Specifically, I would like to show the next concert at the top of the page, currently I can only sort by the date the posts were added (in the get_posts function). This is no good. If possible I would also like to specify a

for each month. so all of Junes concerts are in one
then July are in another and so on. you can see how it looks http://dev.hatfieldband.co.uk/bookings.php. I would like the grouping to look similar to http://www.hatfieldband.co.uk/bookings.html.

Thanks

Sponsor our Newsletter | Privacy Policy | Terms of Service