rendered paste body<?php get_header(); ?>
<div id="content" class="narrowcolumn">
<?php
$cm = date(n);
$year = date(Y);
$secondmonth = date(n) + 1 ;
if ($secondmonth > 12) {$secondmonth = $secondmonth - 12 ; $secondmonthyear = $year +1 ;} else {$secondmonthyear = $year;}
$thirdmonth = $secondmonth + 1;
if ($thirdmonth > 12) { $thirdmonth = $thirdmonth - 12 ;$secondmonthyear = $year +1 ;}else {$thirdmonthyear = $secondmonthyear;}
$fourthmonth = $thirdmonth + 1;
if ($fourthmonth > 12) { $fourthmonth = $fourthmonth - 12 ;$fourthmonthyear = $year +1 ;}else {$fourthmonthyear = $thirdmonthyear;}
$fifthmonth = $fourthmonth + 1;
if ($fifthmonth > 12) { $fifthmonth = $fifthmonth - 12 ;$fifthmonthyear = $year +1 ;}else {$fifthmonthyear = $fourthmonthyear;}
$sixthmonth = $fifthmonth + 1;
if ($sixthmonth > 12) { $sixthmonth = $sixthmonth - 12 ;$sixthmonthyear = $year +1 ;}else {$sixthmonthyear = $fifthmonthyear;}
$seventhmonth = $sixthmonth + 1;
if ($seventhmonth > 12) {$seventhmonth = $seventhmonth - 12 ;$seventhmonthyear = $year +1 ;}else {$seventhmonthyear = $sixthmonthyear;}
$eighthmonth = $seventhmonth + 1;
if ($eighthmonth > 12) {$eighthmonth =$eighthmonth - 12 ;$eighthmonthyear = $year +1 ;}else {$eighthmonthyear = $seventhmonthyear;}
$ninthmonth = $eighthmonth + 1;
if ($ninthmonth > 12) {$ninthmonth = $ninthmonth - 12 ;$ninthmonthyear = $year +1 ;} else {$ninthmonthyear = $eighthmonthyear;}
$tenthmonth = $ninthmonth +1;
if ($tenthmonth > 12) {$tenthmonth = $tenthmonth - 12 ; $tenthmonthyear = $year +1 ;}else {$tenthmonthyear = $ninthmonthyear;}
$eleventhmonth = $tenthmonth + 1;
if ($eleventhmonth > 12) {$eleventhmonth = $eleventhmonth - 12 ;$eleventhmonthyear = $year +1 ;}else {$eleventhmonthyear = $tenthmonthyear;}
$twelthmonth = $eleventhmonth + 1;
if ($twelthmonth > 12) {$twelthmonth = $twelthmonth - 12 ;$twelthmonthyear = $year +1 ;}else {$twelthmonthyear = $eleventhmonthyear;}
$j01= "January";
$f02= "Febuary";
$m03= "March";
$a04= "April";
$m05= "May";
$j06= "June";
$j07= "July";
$a08= "August";
$s09= "September";
$o10= "October";
$n11= "November";
$d12= "December";
if ($cm == 1) {$currentmonthname = $j01 ; $secondmonthname = $f02 ; $thirdmonthname = $m03 ; $fourthmonthname = $a04 ; $fifthmonthname = $m05 ; $sixthmonthname = $j06 ; $seventhmonthname = $j07 ; $eighthmonthname = $a08 ; $ninthmonthname = $s09 ; $tenthmonthname = $o10 ; $eleventhmonthname = $n11 ; $twelthmonthname = $d12 ;}
if ($cm == 2) {$currentmonthname = $f02 ; $secondmonthname = $m03 ; $thirdmonthname = $a04 ; $fourthmonthname = $m05 ; $fifthmonthname = $j06 ; $sixthmonthname = $j07 ; $seventhmonthname = $a08 ; $eighthmonthname = $s09 ; $ninthmonthname = $o10 ; $tenthmonthname = $n11 ; $eleventhmonthname = $d12 ; $twelthmonthname = $j01 ;}
if ($cm == 3) {$currentmonthname = $m03 ; $secondmonthname = $a04 ; $thirdmonthname = $m05 ; $fourthmonthname = $j06 ; $fifthmonthname = $j07 ; $sixthmonthname = $a08 ; $seventhmonthname = $s09 ; $eighthmonthname = $o10 ; $ninthmonthname = $n11 ; $tenthmonthname = $d12 ; $eleventhmonthname = $j01 ; $twelthmonthname = $f02 ;}
if ($cm == 4) {$currentmonthname = $a04 ; $secondmonthname = $m05 ; $thirdmonthname = $j06 ; $fourthmonthname = $j07 ; $fifthmonthname = $a08 ; $sixthmonthname = $s09 ; $seventhmonthname = $o10 ; $eighthmonthname = $n11 ; $ninthmonthname = $d12 ; $tenthmonthname = $j01 ; $eleventhmonthname = $f02 ; $twelthmonthname = $m03 ;}
if ($cm == 5) {$currentmonthname = $m05 ; $secondmonthname = $j06 ; $thirdmonthname = $j07 ; $fourthmonthname = $a08 ; $fifthmonthname = $s09 ; $sixthmonthname = $o10 ; $seventhmonthname = $n11 ; $eighthmonthname = $d12 ; $ninthmonthname = $j01 ; $tenthmonthname = $f02 ; $eleventhmonthname = $m03 ; $twelthmonthname = $a04 ;}
if ($cm == 6) {$currentmonthname = $j06 ; $secondmonthname = $j07 ; $thirdmonthname = $a08 ; $fourthmonthname = $s09 ; $fifthmonthname = $o10 ; $sixthmonthname = $n11 ; $seventhmonthname = $d12 ; $eighthmonthname = $j01 ; $ninthmonthname = $f02 ; $tenthmonthname = $m03 ; $eleventhmonthname = $a04 ; $twelthmonthname = $m05 ;}
if ($cm == 7) {$currentmonthname = $j07 ; $secondmonthname = $a08 ; $thirdmonthname = $s09 ; $fourthmonthname = $o10 ; $fifthmonthname = $n11 ; $sixthmonthname = $d12 ; $seventhmonthname = $j01 ; $eighthmonthname = $f02 ; $ninthmonthname = $m03 ; $tenthmonthname = $a04 ; $eleventhmonthname = $m05 ; $twelthmonthname = $j06 ;}
if ($cm == 8) {$currentmonthname = $a08 ; $secondmonthname = $s09 ; $thirdmonthname = $o10 ; $fourthmonthname = $n11 ; $fifthmonthname = $d12 ; $sixthmonthname = $j01 ; $seventhmonthname = $f02 ; $eighthmonthname = $m03 ; $ninthmonthname = $a04 ; $tenthmonthname = $m05 ; $eleventhmonthname = $j06 ; $twelthmonthname = $j07 ;}
if ($cm == 9) {$currentmonthname = $s09 ; $secondmonthname = $o10 ; $thirdmonthname = $n11 ; $fourthmonthname = $d12 ; $fifthmonthname = $j01 ; $sixthmonthname = $f02 ; $seventhmonthname = $m03 ; $eighthmonthname = $a04 ; $ninthmonthname = $m05 ; $tenthmonthname = $j06 ; $eleventhmonthname = $j07 ; $twelthmonthname = $a08 ;}
if ($cm == 10) {$currentmonthname = $o10 ; $secondmonthname = $n11 ; $thirdmonthname = $d12 ; $fourthmonthname = $j01 ; $fifthmonthname = $f02 ; $sixthmonthname = $m03 ; $seventhmonthname = $a04 ; $eighthmonthname = $m05 ; $ninthmonthname = $j06 ; $tenthmonthname = $j07 ; $eleventhmonthname = $a08 ; $twelthmonthname = $s09 ;}
if ($cm == 11) {$currentmonthname = $n11 ; $secondmonthname = $d12 ; $thirdmonthname = $j01 ; $fourthmonthname = $f02 ; $fifthmonthname = $m03 ; $sixthmonthname = $a04 ; $seventhmonthname = $m05 ; $eighthmonthname = $j06 ; $ninthmonthname = $j07 ; $tenthmonthname = $a08 ; $eleventhmonthname = $s09 ; $twelthmonthname = $o10 ;}
if ($cm == 12) {$currentmonthname = $d12 ; $secondmonthname = $j01 ; $thirdmonthname = $f02 ; $fourthmonthname = $m03 ; $fifthmonthname = $a04 ; $sixthmonthname = $m05 ; $seventhmonthname = $j06 ; $eighthmonthname = $j07 ; $ninthmonthname = $a08 ; $tenthmonthname = $s09 ; $eleventhmonthname = $o10 ; $twelthmonthname = $n11 ;}
$cat1 = "$currentmonthname $year" ;
$cat2 = "$secondmonthname $secondmonthyear";
$cat3 = "$thirdmonthname $thirdmonthyear" ;
$cat4 = "$fourthmonthname $fourthmonthyear";
$cat5 = "$fifthmonthname $fifthmonthyear" ;
$cat6 = "$sixthmonthname $sixthmonthyear" ;
$cat7 = "$seventhmonthname $seventhmonthyear";
$cat8 = "$eighthmonthname $eighthmonthyear";
$cat9 = "$ninthmonthname $ninthmonthyear" ;
$cat10 = "$tenthmonthname $tenthmonthyear" ;
$cat11 = "$eleventhmonthname $eleventhmonthyear";
$cat12 = "$twelthmonthname $twelthmonthyear";
?>
<?php
$querystr = "
SELECT * FROM $wpdb->posts
LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)
WHERE $wpdb->terms.name = '$cat1'
AND $wpdb->term_taxonomy.taxonomy = 'category'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->postmeta.meta_key = 'eventdate'
ORDER BY $wpdb->postmeta.meta_value ASC
";
$pageposts = $wpdb->get_results($querystr, OBJECT);
?>
<h2> <?php echo $cat1 ?></h2>
<?php if ($pageposts): ?>
<?php foreach ($pageposts as $post): ?>
<?php setup_postdata($post); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2> <?php $key="eventdate1"; echo get_post_meta($post->ID, $key, true); ?> <?php $key="eventdate2"; echo get_post_meta($post->ID, $key, true); ?> <?php $key="eventdate3"; echo get_post_meta($post->ID, $key, true); ?> <?php $key="eventdate4"; echo get_post_meta($post->ID, $key, true); ?> <?php $key="eventdate5"; echo get_post_meta($post->ID, $key, true); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?></a></h2>
</div>
<?php endforeach; ?>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Nothings booked yet for <?php echo $cat1 ?>, but if you join the mailing list you'll be amongst the first to know when something is.</p>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>