Creating an archive page for an events schedule
-
Using Types, I created custom taxonomies for a conference. I have the custom post type “session” for conference sessions, as well as the custom taxonomy “semester”, into which sessions are sorted. These conferences typically go over two days, and I would now like to create an archive page which is basically the schedule for the event, with events listed by the custom field ‘start date’. Also, it is important that each day for each conference has its own headline and table containing the sessions.
I’ve tried rather unsuccessfully to create such an archive page, but I have two major problems:
1) The page currently lists ALL sessions, regardless of which semester I navigate to. So even if I navigate to semester 1, I see events for semester 2.
2) The page lists only the events for first day of the conference, but not the events of the second day.
So to combine those two problems, regardless of which semester I navigate to, it only shows me the events of the (upcoming) first day of the conference, but not the second day.
I would be very glad if someone could fix this query for me (I’d be happy to credit you as well).
Here’s the code:
(also at https://pastebin.com/ZYXFQN6Y)<?php get_header(); ?> <section class="index-post-list"> <?php $term = $wp_query->queried_object; $getterm = $term->slug; $args = (array( 'post_type' => 'session', 'tax_query' => array( 'taxonomy' => 'semester', 'field' => 'slug', 'terms' => $getterm, 'include_children' => true, 'operator' => 'IN' ), 'meta_key' => 'wpcf-start-time', 'orderby' => 'meta_value', 'order' => 'ASC' ) ); $query = new wp_query( $args ); $sortdate = $startdate = 0; $table_open = false; ?> <h2 class="archive-title"><?php printf( __( 'Schedule for %s', 'sem' ), single_tag_title( '', false ) ); ?></h2> <?php echo tag_description(); ?> <?php if ( $query -> have_posts() ) : while ( $query -> have_posts() ) : $query -> the_post(); ?> <?php $speaker = types_render_field ( "speaker", array( ) ); $starttimestamp = types_render_field ( "start-time", array("raw"=>"true") ); $endtimestamp = types_render_field ( "end-time", array("raw"=>"true") ); $startdate = date('j M Y', $starttimestamp); $enddate = date('j M Y', $endtimestamp); $starttime = date('H:i', $starttimestamp); $endtime = date('H:i', $endtimestamp); $now = time(); if (($starttimestamp > $now)) { ?> <?php if ($startdate != $sortdate) : ?> <?php if ($table_open == true) : ?> </table> <?php else: ?> <?php endif; ?> <h3><?php echo $startdate; ?></h3> <table class="table table-hover"> <?php $table_open = true; ?> <?php endif; ?> <?php $sortdate = $startdate; ?> <tr class="post" id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <td rowspan="2" width="15%"> <?php /*?><td rowspan="3" width="15%"><?php */?> <?php echo $starttime; ?> - <?php echo $endtime; ?> </td> <td> <h4 class="entry-title"><a>" rel="bookmark"><?php the_title(); ?></a></h4> </td> </tr> <?php /*?><tr> <td class="text-justify"> <?php the_content(); ?> </td> </tr><?php */?> <tr> <td> <?php echo $speaker ?> </td> </tr> <?php } else { ?> <?php } ?> <?php endwhile; ?> </table> <?php else: ?> <p>The schedule will be available shortly before the conference.</p> <?php endif; ?> <?php wp_reset_postdata(); ?> </section><!--index-post-list--> <?php get_footer(); ?>
- The topic ‘Creating an archive page for an events schedule’ is closed to new replies.