How to Display Location, Time, Date and Speakers in the Session Detail.

  1. Home
  2. Docs
  3. Fudge
  4. Frequently Asked Question...
  5. How to Display Location, Time, Date and Speakers in the Session Detail.

How to Display Location, Time, Date and Speakers in the Session Detail.

If you want to provide this information in a particular session detail please follow the next steps.

 

1. Please always before editing take a backup of the original file.

2. Open the wp-content/themes/fudge/single.php file

3. Look for this line

<?php the_content(); ?>

 

4. Add the following code after the line above

if( get_post_type( $post )==’session’ ){
$session_id = $post->ID;
$tracks = wp_get_post_terms($session_id, ‘session-track’, array(‘fields’ => ‘all’));
$locations = wp_get_post_terms($session_id, ‘session-location’, array(‘fields’ => ‘all’));
$date = get_post_meta($session_id, ‘date’, true);
$time = get_post_meta($session_id, ‘time’, true);
$end_time = get_post_meta($session_id, ‘end_time’, true);
if (!empty($time)) {
$time_parts = explode(‘:’, $time);
if (count($time_parts) == 2)
$time = date(get_option(“time_format”), mktime($time_parts[0], $time_parts[1], 0));
}
if (!empty($end_time)) {
$time_parts = explode(‘:’, $end_time);
if (count($time_parts) == 2)
$end_time = date(get_option(“time_format”), mktime($time_parts[0], $time_parts[1], 0));
}

$speakers = array();
$speakers_list = get_post_meta($session_id, ‘speakers_list’, true);
if (!empty($speakers_list)) {
foreach ($speakers_list as $speaker_id)
$speakers[] = array(
‘post_id’ => $speaker_id,
‘post_title’ => apply_filters(‘the_title’, get_the_title($speaker_id)),
‘post_image’ => get_the_post_thumbnail($speaker_id, array(60, 60)),
);
}
?>
<p>

<a class=”btn main-bkg-color tag” title=”<?php echo $tracks[0]->name; ?>” href=”javascript:void(0);” style=”background-color: ‘ <?php echo $tracks[0]->color; ?> ‘!important;”><?php echo $tracks[0]->name; ?></a>
</p>
<div class=”single session-details” >
<p> <span> Location: </span><?php echo $locations[0]->name ;?></p>
<p><span>Date:</span> <?php echo date(get_option(‘date_format’), timestamp_fix($date)) ; ?> </p>
<p><span >Time:</span> <?php echo $time .” – ” .$end_time?></p>
</div>
<?php
foreach($speakers as $speaker ){ ?>
<div class=”single session-speaker”>
<?php echo $speaker[‘post_image’]; ?>
<span data-id=”<?php echo $speaker[‘post_id’] ?>”><?php echo $speaker[‘post_title’] ;?></span>
</div>

<?php }?>

<?php } ?>

 

5. Then open your style sheet and add this style before the mobile version style starts (/*****MEDIA QUERIES FOR MOBILE STYLES *****/)

.single .session-details p { margin: 0 0 5px; }
.single .session-details p a { color:#2a1010; }
.single .session-details span{ color: #121212; display: inline-block; font: bold 16px Montserrat; text-transform: uppercase; width: 100px; }
.single .session-speaker { background: #f1f1f1; border-radius: 6px; float: left; margin: 10px 0 0; padding: 16px; width: 100%; }
.single .session-speaker span { color: #121212; display: inline-block; font: bold 16px Montserrat; margin: 20px 30px 0 0; text-transform: uppercase; cursor: pointer; }
.single .session-speaker img { float: left; margin-right: 10px; }

 

6. Update both files.

 

Now the location, time, date and speakers should be showing in your session detail.

Was this article helpful to you? Yes 2 No