我的朋友设法为我的问题创建了一个出色的解决方案,我将在此处发布代码,希望将来能对某人有所帮助。
<?php
$begin = strtotime('Monday last week'); // Year . Week
$end = $begin + (21 * 24 * 60 * 60);
$week = -1;
$day = -1;
$table = FALSE;
$this_week = date('W');
query_posts(
array(
'post_type' => 'classes', // Custom Post Type
'order' => 'asc', // Order with earliest first
'orderby' => 'wpcf-date-and-time', // Order by the custom field
'posts_per_page' => -1, // Show all
'meta_key' => 'wpcf-date-and-time', // Key is the custom field
'meta_value' => array($begin, $end), // Array of the current month and next
'meta_compare' => 'BETWEEN', // Between Being and End
'author' => $author_id // Show only the author
)
); // Get posts between now and then
if (have_posts()) : while (have_posts()) : the_post();
$do_not_duplicate = $post->ID;
$time = types_render_field("date-and-time", array("arg1"=>"val1","raw"=>"true")); // Your custom field
$current_week = date('W', $time);
$current_day = date('l', $time);
if ($current_week > $week) {
if ($table) {
echo "</table>";
$table = FALSE;
}
$week = $current_week;
if ($week > $this_week) { $week_str = 'Next week';}
else if ($week < $this_week) { $week_str = 'Last week';}
else { $week_str = 'This week';}
echo '<h2 class="">' . $week_str . '</h2>';
}
if ($current_day != $day) {
$day = $current_day;
if ($table) {
echo "</table>";
$table = FALSE;
}
$table = TRUE;
echo '<h3 class="">' . $day . '</h3>';
echo '<table>
<thead>
<tr>
<td>Location</td>
<td>Venue</td>
<td>Time</td>
<td>age</td>
</tr>
</thead>';
}
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php echo(types_render_field("location", array("arg1"=>"val1","arg2"=>"val2"))); ?></td>
<td><?php echo(types_render_field("venue", array("arg1"=>"val1","arg2"=>"val2"))); ?></td>
<td><?php echo get_the_term_list( $post->ID, 'age-group', '', ', ', '' ) ?></td>
</tr>
<?php endwhile; else: ?>
<p>We don't currently have any classes available on this day,
but we can <strong>book your child in for a class</strong>, please get in touch to organise this</p>
<?php endif; wp_reset_query() ?>