Skip to content

Instantly share code, notes, and snippets.

@marisqaporter
Created March 1, 2016 00:06
Show Gist options
  • Save marisqaporter/8b71a4257cc57e43452b to your computer and use it in GitHub Desktop.
Save marisqaporter/8b71a4257cc57e43452b to your computer and use it in GitHub Desktop.
php loop with date picker
<?php
$args = array(
'post_type' => 'volunteer-opportunit', // enter your custom post type
'orderby' => 'date', // order
'order'=> 'ASC', //reverse order
);
$loop = new WP_Query( $args );
if( $loop->have_posts() ):
echo '<div class="row stretch-xs center-xs">';
while( $loop->have_posts() ): $loop->the_post(); global $post;
echo '<div class="col-xs-12
col-sm-12
col-md-4
col-lg-4 row stretch-xs">';
?>
<div class="box staff-box volunteer-box">
<!-- the image -->
<?php
$size = 'volunteer';
$image = get_field('volunteer_image');
if( $image ) {
echo wp_get_attachment_image( $image, $size );
}
?>
<!-- the image -->
<div style="min-height:80px;"><?php the_title( '<h3 class="collapse-top">', '</h3>' ); ?></div>
<!--if for the date -->
<div class="date-wrapper">
<?php
$selected = get_field ('dates_check');
$date1 = get_field('vo_date_start_date');
$startdate = date("F j", strtotime($date1));
$date2 = get_field('vo_date_end_time');
$enddate = date("- j, Y", strtotime($date2));
$ongoing = "ongoing";
$time = get_field('time');
if( in_array('date', $selected) ) {
?><h4 class="left blue collapse"><?php echo $startdate; ?> <?php echo $enddate; ?></h4>
<h4 class="left blue collapse"><?php echo $time; ?></h4>
<?php
}
else if (in_array('ongoing', $selected ) ) {
?><h4 class="left blue collapse"><?php echo $ongoing; ?></h4>
<h4 class="left blue"></h4><?php
}
?>
</div>
<!-- end if statement for date -->
<a class="button ghost-button left-button">Volunteer</a>
</div>
<div class="spacer spacer-60"></div>
<?php
echo '</div>'; //end section inner
endwhile;
echo '</div>'; //end row
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment